class SyntaxTree::Op
Op
represents an operator literal in the source.
1 + 2
In
the example above, the Op
node represents the + operator.
Attributes
- Symbol
-
the symbol version of the value
- String
-
the operator
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 8010 def initialize(value:, location:) @value = value @name = value.to_sym @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 8043 def ===(other) other.is_a?(Op) && value === other.value end
Source
# File lib/syntax_tree/node.rb, line 8017 def accept(visitor) visitor.visit_op(self) end
Source
# File lib/syntax_tree/node.rb, line 8021 def child_nodes [] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 8025 def copy(value: nil, location: nil) node = Op.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 8035 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end