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/ARef.html below:

class SyntaxTree::ARef - RDoc Documentation

  1. SyntaxTree::
  2. ARef
class SyntaxTree::ARef

ARef represents when you’re pulling a value out of a collection at a specific index. Put another way, it’s any time you’re calling the method [].

collection[index]

The nodes usually contains two children, the collection and the index. In some cases, you don’t necessarily have the second child node, because you can call procs with a pretty esoteric syntax. In the following example, you wouldn’t have a second child node:

collection[]
Attributes
Node

the value being indexed

nil | Args

the value being passed within the brackets

Public Class Methods

Source

def initialize(collection:, index:, location:)
  @collection = collection
  @index = index
  @location = location
  @comments = []
end
Public Instance Methods

Source

def ===(other)
  other.is_a?(ARef) && collection === other.collection &&
    index === other.index
end

Source

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

Source

def child_nodes
  [collection, index]
end

Source

def copy(collection: nil, index: nil, location: nil)
  node =
    ARef.new(
      collection: collection || self.collection,
      index: index || self.index,
      location: location || self.location
    )

  node.comments.concat(comments.map(&:copy))
  node
end

Source

def deconstruct_keys(_keys)
  {
    collection: collection,
    index: index,
    location: location,
    comments: comments
  }
end

Source

def format(q)
  q.group do
    q.format(collection)
    q.text("[")

    if index
      q.indent do
        q.breakable_empty
        q.format(index)
      end
      q.breakable_empty
    end

    q.text("]")
  end
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