class SyntaxTree::Field
Field
is always the child of an assignment. It represents assigning to a “field” on an object.
object.variable = value
Attributes
parent[R]
Node
-
the parent object that owns the field being assigned
Public Class Methods
new(parent:, operator:, name:, location:)
click to toggle source
# File lib/syntax_tree/node.rb, line 5304 def initialize(parent:, operator:, name:, location:) @parent = parent @operator = operator @name = name @location = location @comments = [] end
Public Instance Methods
===(other)
click to toggle source
# File lib/syntax_tree/node.rb, line 5354 def ===(other) other.is_a?(Field) && parent === other.parent && operator === other.operator && name === other.name end
accept(visitor)
click to toggle source
# File lib/syntax_tree/node.rb, line 5312 def accept(visitor) visitor.visit_field(self) end
child_nodes()
click to toggle source
# File lib/syntax_tree/node.rb, line 5316 def child_nodes operator = self.operator [parent, (operator if operator != :"::"), name] end
Also aliased as: deconstruct
copy(parent: nil, operator: nil, name: nil, location: nil)
click to toggle source
# File lib/syntax_tree/node.rb, line 5321 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
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/node.rb, line 5336 def deconstruct_keys(_keys) { parent: parent, operator: operator, name: name, location: location, comments: comments } end
format(q)
click to toggle source
# File lib/syntax_tree/node.rb, line 5346 def format(q) q.group do q.format(parent) q.format(CallOperatorFormatter.new(operator), stackable: false) q.format(name) end end