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[nil | Node].
-
#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.
-
#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.
15811 15812 15813 15814 15815 15816 15817 15818 |
# File 'lib/prism/node.rb', line 15811 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]
15854 15855 15856 |
# File 'lib/prism/node.rb', line 15854 def names @names end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
15879 15880 15881 |
# File 'lib/prism/node.rb', line 15879 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.
15885 15886 15887 15888 15889 15890 |
# File 'lib/prism/node.rb', line 15885 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
15821 15822 15823 |
# File 'lib/prism/node.rb', line 15821 def accept(visitor) visitor.visit_undef_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
15826 15827 15828 |
# File 'lib/prism/node.rb', line 15826 def child_nodes [*names] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
15836 15837 15838 |
# File 'lib/prism/node.rb', line 15836 def comment_targets [*names, keyword_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
15831 15832 15833 |
# File 'lib/prism/node.rb', line 15831 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
15841 15842 15843 |
# File 'lib/prism/node.rb', line 15841 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 }
15849 15850 15851 |
# File 'lib/prism/node.rb', line 15849 def deconstruct_keys(keys) { node_id: node_id, location: location, names: names, keyword_loc: keyword_loc } end |
#inspect ⇒ Object
def inspect -> String
15869 15870 15871 |
# File 'lib/prism/node.rb', line 15869 def inspect InspectVisitor.compose(self) end |
#keyword ⇒ Object
def keyword: () -> String
15864 15865 15866 |
# File 'lib/prism/node.rb', line 15864 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location
15857 15858 15859 15860 15861 |
# File 'lib/prism/node.rb', line 15857 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
15874 15875 15876 |
# File 'lib/prism/node.rb', line 15874 def type :undef_node end |