class SyntaxTree::YieldNode
Yield represents using the yield
keyword with arguments.
yield value
Attributes
Public Class Methods
new(arguments:, location:)
click to toggle source
# File lib/syntax_tree/node.rb, line 12280 def initialize(arguments:, location:) @arguments = arguments @location = location @comments = [] end
Public Instance Methods
===(other)
click to toggle source
# File lib/syntax_tree/node.rb, line 12334 def ===(other) other.is_a?(YieldNode) && arguments === other.arguments end
accept(visitor)
click to toggle source
# File lib/syntax_tree/node.rb, line 12286 def accept(visitor) visitor.visit_yield(self) end
child_nodes()
click to toggle source
# File lib/syntax_tree/node.rb, line 12290 def child_nodes [arguments] end
Also aliased as: deconstruct
copy(arguments: nil, location: nil)
click to toggle source
# File lib/syntax_tree/node.rb, line 12294 def copy(arguments: nil, location: nil) node = YieldNode.new( arguments: arguments || self.arguments, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/node.rb, line 12307 def deconstruct_keys(_keys) { arguments: arguments, location: location, comments: comments } end
format(q)
click to toggle source
# File lib/syntax_tree/node.rb, line 12311 def format(q) if arguments.nil? q.text("yield") return end q.group do q.text("yield") if arguments.is_a?(Paren) q.format(arguments) else q.if_break { q.text("(") }.if_flat { q.text(" ") } q.indent do q.breakable_empty q.format(arguments) end q.breakable_empty q.if_break { q.text(")") } end end end