class Prism::EnsureNode

表示 `begin` 语句中的 `ensure` 子句。

begin
  foo
ensure
^^^^^^
  bar
end

属性

statements[R]

attr_reader statements: StatementsNode?

公共类方法

new(source, node_id, location, flags, ensure_keyword_loc, statements, end_keyword_loc) 点击以切换源代码

初始化一个新的 EnsureNode 节点。

# File prism/node.rb, line 6629
def initialize(source, node_id, location, flags, ensure_keyword_loc, statements, end_keyword_loc)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @ensure_keyword_loc = ensure_keyword_loc
  @statements = statements
  @end_keyword_loc = end_keyword_loc
end
type() 点击以切换源代码

返回此节点类型的符号表示。请参阅 ‘Node::type`。

# File prism/node.rb, line 6724
def self.type
  :ensure_node
end

公共实例方法

===(other) 点击以切换源代码

为节点实现 case-equality。这实际上是 ==,但不比较位置的值。位置仅检查是否存在。

# File prism/node.rb, line 6730
def ===(other)
  other.is_a?(EnsureNode) &&
    (ensure_keyword_loc.nil? == other.ensure_keyword_loc.nil?) &&
    (statements === other.statements) &&
    (end_keyword_loc.nil? == other.end_keyword_loc.nil?)
end
accept(visitor) 点击以切换源代码

def accept: (Visitor visitor) -> void

# File prism/node.rb, line 6640
def accept(visitor)
  visitor.visit_ensure_node(self)
end
child_nodes() 点击以切换源代码

def child_nodes: () -> Array[nil | Node]

# File prism/node.rb, line 6645
def child_nodes
  [statements]
end
也别名为: deconstruct
comment_targets() 点击以切换源代码

def comment_targets: () -> Array[Node | Location]

# File prism/node.rb, line 6657
def comment_targets
  [ensure_keyword_loc, *statements, end_keyword_loc] #: Array[Prism::node | Location]
end
compact_child_nodes() 点击以切换源代码

def compact_child_nodes: () -> Array

# File prism/node.rb, line 6650
def compact_child_nodes
  compact = [] #: Array[Prism::node]
  compact << statements if statements
  compact
end
copy(node_id: self.node_id, location: self.location, flags: self.flags, ensure_keyword_loc: self.ensure_keyword_loc, statements: self.statements, end_keyword_loc: self.end_keyword_loc) 点击以切换源代码

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?ensure_keyword_loc: Location, ?statements: StatementsNode?, ?end_keyword_loc: Location) -> EnsureNode

# File prism/node.rb, line 6662
def copy(node_id: self.node_id, location: self.location, flags: self.flags, ensure_keyword_loc: self.ensure_keyword_loc, statements: self.statements, end_keyword_loc: self.end_keyword_loc)
  EnsureNode.new(source, node_id, location, flags, ensure_keyword_loc, statements, end_keyword_loc)
end
deconstruct()

def deconstruct: () -> Array[nil | Node]

别名为: child_nodes
deconstruct_keys(keys) 点击以切换源代码

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, ensure_keyword_loc: Location, statements: StatementsNode?, end_keyword_loc: Location }

# File prism/node.rb, line 6670
def deconstruct_keys(keys)
  { node_id: node_id, location: location, ensure_keyword_loc: ensure_keyword_loc, statements: statements, end_keyword_loc: end_keyword_loc }
end
end_keyword() 点击以切换源代码

def end_keyword: () -> String

# File prism/node.rb, line 6709
def end_keyword
  end_keyword_loc.slice
end
end_keyword_loc() 点击以切换源代码

attr_reader end_keyword_loc: Location

# File prism/node.rb, line 6691
def end_keyword_loc
  location = @end_keyword_loc
  return location if location.is_a?(Location)
  @end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
end
ensure_keyword() 点击以切换源代码

def ensure_keyword: () -> String

# File prism/node.rb, line 6704
def ensure_keyword
  ensure_keyword_loc.slice
end
ensure_keyword_loc() 点击以切换源代码

attr_reader ensure_keyword_loc: Location

# File prism/node.rb, line 6675
def ensure_keyword_loc
  location = @ensure_keyword_loc
  return location if location.is_a?(Location)
  @ensure_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
end
inspect() 点击以切换源代码

def inspect -> String

# File prism/node.rb, line 6714
def inspect
  InspectVisitor.compose(self)
end
save_end_keyword_loc(repository) 点击以切换源代码

使用给定的保存的源保存 end_keyword_loc 位置,以便稍后可以检索它。

# File prism/node.rb, line 6699
def save_end_keyword_loc(repository)
  repository.enter(node_id, :end_keyword_loc)
end
save_ensure_keyword_loc(repository) 点击以切换源代码

使用给定的保存的源保存 ensure_keyword_loc 位置,以便稍后可以检索它。

# File prism/node.rb, line 6683
def save_ensure_keyword_loc(repository)
  repository.enter(node_id, :ensure_keyword_loc)
end
type() 点击以切换源代码

返回此节点类型的符号表示。请参阅 ‘Node#type`。

# File prism/node.rb, line 6719
def type
  :ensure_node
end