class Prism::ReturnNode
Представляет использование ключевого слова return.
return 1 ^^^^^^^^
Атрибуты
attr_reader arguments: ArgumentsNode?
Открытые методы класса
# File lib/prism/node.rb, line 16244 def initialize(source, node_id, location, flags, keyword_loc, arguments) @source = source @node_id = node_id @location = location @flags = flags @keyword_loc = keyword_loc @arguments = arguments end
Инициализирует новый узел ReturnNode.
# File lib/prism/node.rb, line 16320 def self.type :return_node end
Возвращает символьное представление типа этого узла. См. Node::type.
Открытые методы экземпляра
# File lib/prism/node.rb, line 16326
def ===(other)
other.is_a?(ReturnNode) &&
(keyword_loc.nil? == other.keyword_loc.nil?) &&
(arguments === other.arguments)
end Реализует сравнение на соответствие с образцом для узла. По сути, это оператор ==, но без сравнения значений расположений. Проверяется только наличие расположений.
# File lib/prism/node.rb, line 16254 def accept(visitor) visitor.visit_return_node(self) end
def accept: (Visitor visitor) -> void
# File lib/prism/node.rb, line 16259 def child_nodes [arguments] end
def child_nodes: () -> Array
# File lib/prism/node.rb, line 16271 def comment_targets [keyword_loc, *arguments] #: Array[Prism::node | Location] end
def comment_targets: () -> Array[Node | Location]
# File lib/prism/node.rb, line 16264 def compact_child_nodes compact = [] #: Array[Prism::node] compact << arguments if arguments compact end
def compact_child_nodes: () -> Array
# File lib/prism/node.rb, line 16276 def copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, arguments: self.arguments) ReturnNode.new(source, node_id, location, flags, keyword_loc, arguments) end
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?arguments: ArgumentsNode?) -> ReturnNode
# File lib/prism/node.rb, line 16284
def deconstruct_keys(keys)
{ node_id: node_id, location: location, keyword_loc: keyword_loc, arguments: arguments }
end def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, keyword_loc: Location, arguments: ArgumentsNode? }
# File lib/prism/node.rb, line 16310 def inspect InspectVisitor.compose(self) end
def inspect -> String
# File lib/prism/node.rb, line 16305 def keyword keyword_loc.slice end
def keyword: () -> String
# File lib/prism/node.rb, line 16289 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
attr_reader keyword_loc: Location
# File lib/prism/node.rb, line 16297 def save_keyword_loc(repository) repository.enter(node_id, :keyword_loc) end
Сохраняет расположение keyword_loc, используя переданный сохранённый исходный код, чтобы его можно было получить позднее.
# File lib/prism/node.rb, line 16315 def type :return_node end
Возвращает символьное представление типа этого узла. См. Node#type.
Ruby Core © 1993–2025 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.