Class: SyntaxTree::Op
Overview
Op represents an operator literal in the source.
1 + 2
In the example above, the Op node represents the + operator.
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- String
-
the operator.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ Op
constructor
A new instance of Op.
Methods inherited from Node
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Op
Returns a new instance of Op.
5805 5806 5807 5808 5809 |
# File 'lib/syntax_tree/node.rb', line 5805 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5803 5804 5805 |
# File 'lib/syntax_tree/node.rb', line 5803 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the operator
5800 5801 5802 |
# File 'lib/syntax_tree/node.rb', line 5800 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
5811 5812 5813 |
# File 'lib/syntax_tree/node.rb', line 5811 def accept(visitor) visitor.visit_op(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5815 5816 5817 |
# File 'lib/syntax_tree/node.rb', line 5815 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
5821 5822 5823 |
# File 'lib/syntax_tree/node.rb', line 5821 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
5825 5826 5827 |
# File 'lib/syntax_tree/node.rb', line 5825 def format(q) q.text(value) end |