Class: Prism::BlockLocalVariableNode

Inherits:
PrismNode
  • Object
show all
Defined in:
lib/prism/node.rb,
ext/prism/api_node.c

Overview

Represents a block local variable.

a { |; b| }
       ^

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, name) ⇒ BlockLocalVariableNode

Initialize a new BlockLocalVariableNode node.



1749
1750
1751
1752
1753
1754
1755
# File 'lib/prism/node.rb', line 1749

def initialize(source, node_id, location, flags, name)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

The name of the block local variable.

a { |; b| } # name `:b`
       ^


1799
1800
1801
# File 'lib/prism/node.rb', line 1799

def name
  @name
end

Class Method Details

.typeObject

Return a symbol representation of this node type. See ‘Node::type`.



1812
1813
1814
# File 'lib/prism/node.rb', line 1812

def self.type
  :block_local_variable_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.



1818
1819
1820
1821
1822
# File 'lib/prism/node.rb', line 1818

def ===(other)
  other.is_a?(BlockLocalVariableNode) &&
    (flags === other.flags) &&
    (name === other.name)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



1758
1759
1760
# File 'lib/prism/node.rb', line 1758

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



1763
1764
1765
# File 'lib/prism/node.rb', line 1763

def child_nodes
  []
end

#comment_targetsObject

def comment_targets: () -> Array[Node | Location]



1773
1774
1775
# File 'lib/prism/node.rb', line 1773

def comment_targets
  [] #: Array[Prism::node | Location]
end

#compact_child_nodesObject

def compact_child_nodes: () -> Array



1768
1769
1770
# File 'lib/prism/node.rb', line 1768

def compact_child_nodes
  []
end

#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name) ⇒ Object

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> BlockLocalVariableNode



1778
1779
1780
# File 'lib/prism/node.rb', line 1778

def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name)
  BlockLocalVariableNode.new(source, node_id, location, flags, name)
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }



1786
1787
1788
# File 'lib/prism/node.rb', line 1786

def deconstruct_keys(keys)
  { node_id: node_id, location: location, name: name }
end

#inspectObject

def inspect -> String



1802
1803
1804
# File 'lib/prism/node.rb', line 1802

def inspect
  InspectVisitor.compose(self)
end

#repeated_parameter?Boolean

def repeated_parameter?: () -> bool

Returns:

  • (Boolean)


1791
1792
1793
# File 'lib/prism/node.rb', line 1791

def repeated_parameter?
  flags.anybits?(ParameterFlags::REPEATED_PARAMETER)
end

#typeObject

Return a symbol representation of this node type. See ‘Node#type`.



1807
1808
1809
# File 'lib/prism/node.rb', line 1807

def type
  :block_local_variable_node
end