Spec-Zone.ru › Ruby 3.4

класс Prism::BeginNode

Родитель:
Prism::Node

Представляет оператор begin.

begin
  foo
end
^^^^^

Атрибуты

else_clause [R]

Представляет блок else внутри блока begin.

begin x; rescue y; else z; end
                   ^^^^^^
ensure_clause [R]

Представляет блок ensure внутри блока begin.

begin x; ensure y; end
         ^^^^^^^^
rescue_clause [R]

Представляет блок rescue внутри блока begin.

begin x; rescue y; end
         ^^^^^^^^
statements [R]

Представляет операторы внутри блока begin.

begin x end
      ^

Публичные методы класса

new (source, node_id, location, flags, begin_keyword_loc, statements, rescue_clause, else_clause, ensure_clause, end_keyword_loc)
Исходный код
# File lib/prism/node.rb, line 1485
def initialize(source, node_id, location, flags, begin_keyword_loc, statements, rescue_clause, else_clause, ensure_clause, end_keyword_loc)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @begin_keyword_loc = begin_keyword_loc
  @statements = statements
  @rescue_clause = rescue_clause
  @else_clause = else_clause
  @ensure_clause = ensure_clause
  @end_keyword_loc = end_keyword_loc
end

Инициализирует новый узел BeginNode.

type ()
Исходный код
# File lib/prism/node.rb, line 1625
def self.type
  :begin_node
end

Возвращает символ, представляющий тип этого узла. См. ‘Node::type`.

Публичные методы экземпляра

=== (other)
Исходный код
# File lib/prism/node.rb, line 1631
def ===(other)
  other.is_a?(BeginNode) &&
    (begin_keyword_loc.nil? == other.begin_keyword_loc.nil?) &&
    (statements === other.statements) &&
    (rescue_clause === other.rescue_clause) &&
    (else_clause === other.else_clause) &&
    (ensure_clause === other.ensure_clause) &&
    (end_keyword_loc.nil? == other.end_keyword_loc.nil?)
end

Реализует равенство с учётом регистра для узла. Это фактически ==, но без сравнения значения местоположений. Местоположения проверяются только на наличие.

accept (visitor)
Исходный код
# File lib/prism/node.rb, line 1499
def accept(visitor)
  visitor.visit_begin_node(self)
end

def accept: (Visitor visitor) -> void

begin_keyword ()
Исходный код
# File lib/prism/node.rb, line 1605
def begin_keyword
  begin_keyword_loc&.slice
end

def begin_keyword: () -> String?

begin_keyword_loc ()
Исходный код
# File lib/prism/node.rb, line 1540
def begin_keyword_loc
  location = @begin_keyword_loc
  case location
  when nil
    nil
  when Location
    location
  else
    @begin_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
  end
end

Представляет местоположение ключевого слова ‘begin`.

begin x end
^^^^^
child_nodes ()
Исходный код
# File lib/prism/node.rb, line 1504
def child_nodes
  [statements, rescue_clause, else_clause, ensure_clause]
end

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

Также известен как: deconstruct
comment_targets ()
Исходный код
# File lib/prism/node.rb, line 1519
def comment_targets
  [*begin_keyword_loc, *statements, *rescue_clause, *else_clause, *ensure_clause, *end_keyword_loc] #: Array[Prism::node | Location]
end

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

compact_child_nodes ()
Исходный код
# File lib/prism/node.rb, line 1509
def compact_child_nodes
  compact = [] #: Array[Prism::node]
  compact << statements if statements
  compact << rescue_clause if rescue_clause
  compact << else_clause if else_clause
  compact << ensure_clause if ensure_clause
  compact
end

def compact_child_nodes: () -> Array

copy (node_id: self.node_id, location: self.location, flags: self.flags, begin_keyword_loc: self.begin_keyword_loc, statements: self.statements, rescue_clause: self.rescue_clause, else_clause: self.else_clause, ensure_clause: self.ensure_clause, end_keyword_loc: self.end_keyword_loc)
Исходный код
# File lib/prism/node.rb, line 1524
def copy(node_id: self.node_id, location: self.location, flags: self.flags, begin_keyword_loc: self.begin_keyword_loc, statements: self.statements, rescue_clause: self.rescue_clause, else_clause: self.else_clause, ensure_clause: self.ensure_clause, end_keyword_loc: self.end_keyword_loc)
  BeginNode.new(source, node_id, location, flags, begin_keyword_loc, statements, rescue_clause, else_clause, ensure_clause, end_keyword_loc)
end

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?begin_keyword_loc: Location?, ?statements: StatementsNode?, ?rescue_clause: RescueNode?, ?else_clause: ElseNode?, ?ensure_clause: EnsureNode?, ?end_keyword_loc: Location?) -> BeginNode

deconstruct ()

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

Псевдоним для: child_nodes
deconstruct_keys (keys)
Исходный код
# File lib/prism/node.rb, line 1532
def deconstruct_keys(keys)
  { node_id: node_id, location: location, begin_keyword_loc: begin_keyword_loc, statements: statements, rescue_clause: rescue_clause, else_clause: else_clause, ensure_clause: ensure_clause, end_keyword_loc: end_keyword_loc }
end

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, begin_keyword_loc: Location?, statements: StatementsNode?, rescue_clause: RescueNode?, else_clause: ElseNode?, ensure_clause: EnsureNode?, end_keyword_loc: Location? }

end_keyword ()
Исходный код
# File lib/prism/node.rb, line 1610
def end_keyword
  end_keyword_loc&.slice
end

def end_keyword: () -> String?

end_keyword_loc ()
Исходный код
# File lib/prism/node.rb, line 1586
def end_keyword_loc
  location = @end_keyword_loc
  case location
  when nil
    nil
  when Location
    location
  else
    @end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
  end
end

Представляет местоположение ключевого слова ‘end`.

begin x end
        ^^^
inspect ()
Исходный код
# File lib/prism/node.rb, line 1615
def inspect
  InspectVisitor.compose(self)
end

def inspect -> String

save_begin_keyword_loc (repository)
Исходный код
# File lib/prism/node.rb, line 1554
def save_begin_keyword_loc(repository)
  repository.enter(node_id, :begin_keyword_loc) unless @begin_keyword_loc.nil?
end

Сохраняет местоположение begin_keyword_loc используя заданный сохранённый источник, чтобы его можно было получить позже.

save_end_keyword_loc (repository)
Исходный код
# File lib/prism/node.rb, line 1600
def save_end_keyword_loc(repository)
  repository.enter(node_id, :end_keyword_loc) unless @end_keyword_loc.nil?
end

Сохраняет местоположение end_keyword_loc используя заданный сохранённый источник, чтобы его можно было получить позже.

type ()
Исходный код
# File lib/prism/node.rb, line 1620
def type
  :begin_node
end

Возвращает символьное представление типа узла. См. ‘Node#type`.

Ruby Core © 1993–2024 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API