Class: SyntaxTree::Dot2
Overview
Dot2 represents using the .. operator between two expressions. Usually this is to create a range object.
1..2
Sometimes this operator is used to create a flip-flop.
if value == 5 .. value == 10
end
One of the sides of the expression may be nil, but not both.
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#left ⇒ Object
readonly
- nil | untyped
-
the left side of the expression.
-
#right ⇒ Object
readonly
- nil | untyped
-
the right side of the expression.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(left:, right:, location:, comments: []) ⇒ Dot2
constructor
A new instance of Dot2.
Methods inherited from Node
Constructor Details
#initialize(left:, right:, location:, comments: []) ⇒ Dot2
Returns a new instance of Dot2.
3361 3362 3363 3364 3365 3366 |
# File 'lib/syntax_tree/node.rb', line 3361 def initialize(left:, right:, location:, comments: []) @left = left @right = right @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
3359 3360 3361 |
# File 'lib/syntax_tree/node.rb', line 3359 def comments @comments end |
#left ⇒ Object (readonly)
- nil | untyped
-
the left side of the expression
3353 3354 3355 |
# File 'lib/syntax_tree/node.rb', line 3353 def left @left end |
#right ⇒ Object (readonly)
- nil | untyped
-
the right side of the expression
3356 3357 3358 |
# File 'lib/syntax_tree/node.rb', line 3356 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
3368 3369 3370 |
# File 'lib/syntax_tree/node.rb', line 3368 def accept(visitor) visitor.visit_dot2(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
3372 3373 3374 |
# File 'lib/syntax_tree/node.rb', line 3372 def child_nodes [left, right] end |
#deconstruct_keys(keys) ⇒ Object
3378 3379 3380 |
# File 'lib/syntax_tree/node.rb', line 3378 def deconstruct_keys(keys) { left: left, right: right, location: location, comments: comments } end |
#format(q) ⇒ Object
3382 3383 3384 |
# File 'lib/syntax_tree/node.rb', line 3382 def format(q) DotFormatter.new("..", self).format(q) end |