class SyntaxTree::Field
Field
is always the child of an assignment. It represents assigning to a “field” on an object.
object.variable = value
Attributes
Node
-
the parent object that owns the field being assigned
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 5319 def initialize(parent:, operator:, name:, location:) @parent = parent @operator = operator @name = name @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 5369 def ===(other) other.is_a?(Field) && parent === other.parent && operator === other.operator && name === other.name end
Source
# File lib/syntax_tree/node.rb, line 5327 def accept(visitor) visitor.visit_field(self) end
Source
# File lib/syntax_tree/node.rb, line 5331 def child_nodes operator = self.operator [parent, (operator if operator != :"::"), name] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 5336 def copy(parent: nil, operator: nil, name: nil, location: nil) node = Field.new( parent: parent || self.parent, operator: operator || self.operator, name: name || self.name, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 5351 def deconstruct_keys(_keys) { parent: parent, operator: operator, name: name, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 5361 def format(q) q.group do q.format(parent) q.format(CallOperatorFormatter.new(operator), stackable: false) q.format(name) end end