class SyntaxTree::YieldNode
Yield represents using the yield
keyword with arguments.
yield value
Attributes
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 12299 def initialize(arguments:, location:) @arguments = arguments @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 12353 def ===(other) other.is_a?(YieldNode) && arguments === other.arguments end
Source
# File lib/syntax_tree/node.rb, line 12305 def accept(visitor) visitor.visit_yield(self) end
Source
# File lib/syntax_tree/node.rb, line 12309 def child_nodes [arguments] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 12313 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
Source
# File lib/syntax_tree/node.rb, line 12326 def deconstruct_keys(_keys) { arguments: arguments, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 12330 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