class SyntaxTree::Op
Op
represents an operator literal in the source.
1 + 2
In
the example above, the Op
node represents the + operator.
Attributes
name[R]
- Symbol
-
the symbol version of the value
value[R]
- String
-
the operator
Public Class Methods
new(value:, location:)
click to toggle source
# File lib/syntax_tree/node.rb, line 7995 def initialize(value:, location:) @value = value @name = value.to_sym @location = location @comments = [] end
Public Instance Methods
===(other)
click to toggle source
# File lib/syntax_tree/node.rb, line 8028 def ===(other) other.is_a?(Op) && value === other.value end
accept(visitor)
click to toggle source
# File lib/syntax_tree/node.rb, line 8002 def accept(visitor) visitor.visit_op(self) end
child_nodes()
click to toggle source
# File lib/syntax_tree/node.rb, line 8006 def child_nodes [] end
Also aliased as: deconstruct
copy(value: nil, location: nil)
click to toggle source
# File lib/syntax_tree/node.rb, line 8010 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
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/node.rb, line 8020 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end
format(q)
click to toggle source
# File lib/syntax_tree/node.rb, line 8024 def format(q) q.text(value) end