Class: Prism::UndefNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::UndefNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents the use of the ‘undef` keyword.
undef :foo, :bar, :baz
^^^^^^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
attr_reader names: Array[SymbolNode | InterpolatedSymbolNode].
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array.
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, names: self.names, keyword_loc: self.keyword_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?names: Array[SymbolNode | InterpolatedSymbolNode], ?keyword_loc: Location) -> UndefNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, names: Array[SymbolNode | InterpolatedSymbolNode], keyword_loc: Location }.
-
#initialize(source, node_id, location, flags, names, keyword_loc) ⇒ UndefNode
constructor
Initialize a new UndefNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#keyword ⇒ Object
def keyword: () -> String.
-
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location.
-
#save_keyword_loc(repository) ⇒ Object
Save the keyword_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, names, keyword_loc) ⇒ UndefNode
Initialize a new UndefNode node.
17609 17610 17611 17612 17613 17614 17615 17616 |
# File 'lib/prism/node.rb', line 17609 def initialize(source, node_id, location, flags, names, keyword_loc) @source = source @node_id = node_id @location = location @flags = flags @names = names @keyword_loc = keyword_loc end |
Instance Attribute Details
#names ⇒ Object (readonly)
attr_reader names: Array[SymbolNode | InterpolatedSymbolNode]
17652 17653 17654 |
# File 'lib/prism/node.rb', line 17652 def names @names end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
17683 17684 17685 |
# File 'lib/prism/node.rb', line 17683 def self.type :undef_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
17689 17690 17691 17692 17693 17694 |
# File 'lib/prism/node.rb', line 17689 def ===(other) other.is_a?(UndefNode) && (names.length == other.names.length) && names.zip(other.names).all? { |left, right| left === right } && (keyword_loc.nil? == other.keyword_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
17619 17620 17621 |
# File 'lib/prism/node.rb', line 17619 def accept(visitor) visitor.visit_undef_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
17624 17625 17626 |
# File 'lib/prism/node.rb', line 17624 def child_nodes [*names] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
17634 17635 17636 |
# File 'lib/prism/node.rb', line 17634 def comment_targets [*names, keyword_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
17629 17630 17631 |
# File 'lib/prism/node.rb', line 17629 def compact_child_nodes [*names] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, names: self.names, keyword_loc: self.keyword_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?names: Array[SymbolNode | InterpolatedSymbolNode], ?keyword_loc: Location) -> UndefNode
17639 17640 17641 |
# File 'lib/prism/node.rb', line 17639 def copy(node_id: self.node_id, location: self.location, flags: self.flags, names: self.names, keyword_loc: self.keyword_loc) UndefNode.new(source, node_id, location, flags, names, keyword_loc) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, names: Array[SymbolNode | InterpolatedSymbolNode], keyword_loc: Location }
17647 17648 17649 |
# File 'lib/prism/node.rb', line 17647 def deconstruct_keys(keys) { node_id: node_id, location: location, names: names, keyword_loc: keyword_loc } end |
#inspect ⇒ Object
def inspect -> String
17673 17674 17675 |
# File 'lib/prism/node.rb', line 17673 def inspect InspectVisitor.compose(self) end |
#keyword ⇒ Object
def keyword: () -> String
17668 17669 17670 |
# File 'lib/prism/node.rb', line 17668 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location
17655 17656 17657 17658 17659 |
# File 'lib/prism/node.rb', line 17655 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_keyword_loc(repository) ⇒ Object
Save the keyword_loc location using the given saved source so that it can be retrieved later.
17663 17664 17665 |
# File 'lib/prism/node.rb', line 17663 def save_keyword_loc(repository) repository.enter(node_id, :keyword_loc) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
17678 17679 17680 |
# File 'lib/prism/node.rb', line 17678 def type :undef_node end |