class SyntaxTree::OpAssign
OpAssign
represents assigning a value to a variable or constant using an operator like += or ||=.
variable += value
Attributes
Op
-
the operator being used for the assignment
ARefField
|ConstPathField
|Field
|TopConstField
|VarField
-
the target
to assign the result of the expression to
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 8067 def initialize(target:, operator:, value:, location:) @target = target @operator = operator @value = value @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 8126 def ===(other) other.is_a?(OpAssign) && target === other.target && operator === other.operator && value === other.value end
Source
# File lib/syntax_tree/node.rb, line 8075 def accept(visitor) visitor.visit_opassign(self) end
Source
# File lib/syntax_tree/node.rb, line 8079 def child_nodes [target, operator, value] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 8083 def copy(target: nil, operator: nil, value: nil, location: nil) node = OpAssign.new( target: target || self.target, operator: operator || self.operator, value: value || self.value, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 8098 def deconstruct_keys(_keys) { target: target, operator: operator, value: value, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 8108 def format(q) q.group do q.format(target) q.text(" ") q.format(operator) if skip_indent? q.text(" ") q.format(value) else q.indent do q.breakable_space q.format(value) end end end end