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
Args
the value being passed within the brackets
def initialize(collection:, index:, location:) @collection = collection @index = index @location = location @comments = [] endPublic Instance Methods Source
def ===(other) other.is_a?(ARef) && collection === other.collection && index === other.index endSource
def accept(visitor) visitor.visit_aref(self) endSource
def child_nodes [collection, index] endSource
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 endSource
def deconstruct_keys(_keys) { collection: collection, index: index, location: location, comments: comments } endSource
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