A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://ruby-syntax-tree.github.io/syntax_tree/SyntaxTree/RangeNode.html below:

class SyntaxTree::RangeNode - RDoc Documentation

  1. SyntaxTree::
  2. RangeNode
class SyntaxTree::RangeNode

RangeNode represents using the .. or 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.

Attributes
nil | Node

the left side of the expression

Op

the operator used for this range

nil | Node

the right side of the expression

Public Class Methods

Source

def initialize(left:, operator:, right:, location:)
  @left = left
  @operator = operator
  @right = right
  @location = location
  @comments = []
end
Public Instance Methods

Source

def ===(other)
  other.is_a?(RangeNode) && left === other.left &&
    operator === other.operator && right === other.right
end

Source

def accept(visitor)
  visitor.visit_range(self)
end

Source

def child_nodes
  [left, right]
end

Source

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

Source

def deconstruct_keys(_keys)
  {
    left: left,
    operator: operator,
    right: right,
    location: location,
    comments: comments
  }
end

Source

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4