Class: SyntaxTree::Dot3
Overview
Dot3 represents using the … operator between two expressions. Usually this is to create a range object. It’s effectively the same event as the Dot2 node but with this operator you’re asking Ruby to omit the final value.
1...2
Like Dot2 it can also be 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: []) ⇒ Dot3
constructor
A new instance of Dot3.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(left:, right:, location:, comments: []) ⇒ Dot3
Returns a new instance of Dot3.
3966 3967 3968 3969 3970 3971 |
# File 'lib/syntax_tree/node.rb', line 3966 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
3964 3965 3966 |
# File 'lib/syntax_tree/node.rb', line 3964 def comments @comments end |
#left ⇒ Object (readonly)
- nil | untyped
-
the left side of the expression
3958 3959 3960 |
# File 'lib/syntax_tree/node.rb', line 3958 def left @left end |
#right ⇒ Object (readonly)
- nil | untyped
-
the right side of the expression
3961 3962 3963 |
# File 'lib/syntax_tree/node.rb', line 3961 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
3973 3974 3975 |
# File 'lib/syntax_tree/node.rb', line 3973 def accept(visitor) visitor.visit_dot3(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
3977 3978 3979 |
# File 'lib/syntax_tree/node.rb', line 3977 def child_nodes [left, right] end |
#deconstruct_keys(_keys) ⇒ Object
3983 3984 3985 |
# File 'lib/syntax_tree/node.rb', line 3983 def deconstruct_keys(_keys) { left: left, right: right, location: location, comments: comments } end |
#format(q) ⇒ Object
3987 3988 3989 |
# File 'lib/syntax_tree/node.rb', line 3987 def format(q) DotFormatter.new("...", self).format(q) end |