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
new(value:, location:)
click to toggle source
# File lib/syntax_tree/node.rb, line 11529 def initialize(value:, location:) @value = value @location = location @comments = [] end
Public Instance Methods
===(other)
click to toggle source
# File lib/syntax_tree/node.rb, line 11568 def ===(other) other.is_a?(VarField) && value === other.value end
accept(visitor)
click to toggle source
# File lib/syntax_tree/node.rb, line 11535 def accept(visitor) visitor.visit_var_field(self) end
child_nodes()
click to toggle source
# File lib/syntax_tree/node.rb, line 11539 def child_nodes value == :nil ? [] : [value] end
Also aliased as: deconstruct
copy(value: nil, location: nil)
click to toggle source
# File lib/syntax_tree/node.rb, line 11543 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
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/node.rb, line 11556 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end
format(q)
click to toggle source
# File lib/syntax_tree/node.rb, line 11560 def format(q) if value == :nil q.text("nil") elsif value q.format(value) end end