class SyntaxTree::RangeNode
One of the sides of the expression may be nil, but not both.
end
if value == 5 .. value == 10
Sometimes this operator is used to create a flip-flop.
1..2
expressions. Usually this is to create a range object.
RangeNode represents using the .. or the … operator between two
def ===(other)
def ===(other) other.is_a?(RangeNode) && left === other.left && operator === other.operator && right === other.right end
def accept(visitor)
def accept(visitor) visitor.visit_range(self) end
def child_nodes
def child_nodes [left, right] end
def copy(left: nil, operator: nil, right: nil, location: nil)
def copy(left: nil, operator: nil, right: nil, location: nil) node = RangeNode.new( left: left || self.left, operator: operator || self.operator, right: right || self.right, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { left: left, operator: operator, right: right, location: location, comments: comments } end
def format(q)
def format(q) q.format(left) if left case q.parent when IfNode, UnlessNode q.text(" #{operator.value} ") else q.text(operator.value) end q.format(right) if right end
def initialize(left:, operator:, right:, location:)
def initialize(left:, operator:, right:, location:) @left = left @operator = operator @right = right @location = location @comments = [] end