class Prism::ArrayNode
Represents an array literal. This can be a regular array using brackets or a special array using % like %w or %i.
[1, 2, 3]^^^^^^^^^
Attributes
Represent the list of zero or morenon-void expressions within the array.
Public Class Methods
Source
# File lib/prism/node.rb, line 870definitialize(source,node_id,location,flags,elements,opening_loc,closing_loc)@source =source@node_id =node_id@location =location@flags =flags@elements =elements@opening_loc =opening_loc@closing_loc =closing_locend
Initialize a newArrayNode node.
Source
# File lib/prism/node.rb, line 990defself.type:array_nodeend
Return a symbol representation of this node type. SeeNode::type.
Public Instance Methods
Source
# File lib/prism/node.rb, line 996def===(other)other.is_a?(ArrayNode)&& (flags===other.flags)&& (elements.length==other.elements.length)&&elements.zip(other.elements).all? {|left,right|left===right }&& (opening_loc.nil?==other.opening_loc.nil?)&& (closing_loc.nil?==other.closing_loc.nil?)end
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
Source
# File lib/prism/node.rb, line 881defaccept(visitor)visitor.visit_array_node(self)end
def accept: (Visitor visitor) -> void
Source
# File lib/prism/node.rb, line 886defchild_nodes [*elements]end
defchild_nodes: () ->Array
Source
# File lib/prism/node.rb, line 975defclosingclosing_loc&.sliceend
def closing: () ->String?
Source
# File lib/prism/node.rb, line 951defclosing_loclocation =@closing_loccaselocationwhennilnilwhenLocationlocationelse@closing_loc =Location.new(source,location>>32,location&0xFFFFFFFF)endend
Represents the optional source location for the closing token.
[1,2,3]# "]"%w[foo bar baz]# "]"%I(apple orange banana)# ")"foo =1,2,3# nil
Source
# File lib/prism/node.rb, line 896defcomment_targets [*elements,*opening_loc,*closing_loc]#: Array[Prism::node | Location]end
defcomment_targets: () -> Array[Node | Location]
Source
# File lib/prism/node.rb, line 891defcompact_child_nodes [*elements]end
defcompact_child_nodes: () ->Array
Source
# File lib/prism/node.rb, line 914defcontains_splat?flags.anybits?(ArrayNodeFlags::CONTAINS_SPLAT)end
def contains_splat?: () -> bool
Source
# File lib/prism/node.rb, line 901defcopy(node_id:self.node_id,location:self.location,flags:self.flags,elements:self.elements,opening_loc:self.opening_loc,closing_loc:self.closing_loc)ArrayNode.new(source,node_id,location,flags,elements,opening_loc,closing_loc)end
def copy: (?node_id:Integer, ?location:Location, ?flags:Integer, ?elements:Array, ?opening_loc:Location?, ?closing_loc:Location?) ->ArrayNode
Source
# File lib/prism/node.rb, line 909defdeconstruct_keys(keys) {node_id:node_id,location:location,elements:elements,opening_loc:opening_loc,closing_loc:closing_loc }end
defdeconstruct_keys: (Array keys) -> { node_id:Integer, location:Location, elements:Array,opening_loc:Location?,closing_loc:Location? }
Source
# File lib/prism/node.rb, line 980definspectInspectVisitor.compose(self)end
def inspect ->String
Source
# File lib/prism/node.rb, line 970defopeningopening_loc&.sliceend
def opening: () ->String?
Source
# File lib/prism/node.rb, line 927defopening_loclocation =@opening_loccaselocationwhennilnilwhenLocationlocationelse@opening_loc =Location.new(source,location>>32,location&0xFFFFFFFF)endend
Represents the optional source location for the opening token.
[1,2,3]# "["%w[foo bar baz]# "%w["%I(apple orange banana)# "%I("foo =1,2,3# nil
Source
# File lib/prism/node.rb, line 965defsave_closing_loc(repository)repository.enter(node_id,:closing_loc)unless@closing_loc.nil?end
Save theclosing_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 941defsave_opening_loc(repository)repository.enter(node_id,:opening_loc)unless@opening_loc.nil?end
Save theopening_loc location using the given saved source so that it can be retrieved later.