class SyntaxTree::VarField
VarField
represents a variable that is being assigned a value. As such, it is always a child of an assignment type node.
variable = value
In
the example above, the VarField
node represents the variable
token.
Attributes
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 11544 def initialize(value:, location:) @value = value @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 11583 def ===(other) other.is_a?(VarField) && value === other.value end
Source
# File lib/syntax_tree/node.rb, line 11550 def accept(visitor) visitor.visit_var_field(self) end
Source
# File lib/syntax_tree/node.rb, line 11554 def child_nodes value == :nil ? [] : [value] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 11558 def copy(value: nil, location: nil) node = VarField.new( value: value || self.value, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 11571 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 11575 def format(q) if value == :nil q.text("nil") elsif value q.format(value) end end