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.



1870
1871
1872
1873
1874
1875
1876
# File 'lib/prism/node.rb', line 1870

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`
       ^


1926
1927
1928
# File 'lib/prism/node.rb', line 1926

def name
  @name
end

Class Method Details

.typeObject

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



1939
1940
1941
# File 'lib/prism/node.rb', line 1939

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.



1945
1946
1947
1948
1949
# File 'lib/prism/node.rb', line 1945

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



1879
1880
1881
# File 'lib/prism/node.rb', line 1879

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



1884
1885
1886
# File 'lib/prism/node.rb', line 1884

def child_nodes
  []
end

#comment_targetsObject

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



1900
1901
1902
# File 'lib/prism/node.rb', line 1900

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



1895
1896
1897
# File 'lib/prism/node.rb', line 1895

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



1905
1906
1907
# File 'lib/prism/node.rb', line 1905

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 }



1913
1914
1915
# File 'lib/prism/node.rb', line 1913

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

#each_child_nodeObject

def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator



1889
1890
1891
1892
# File 'lib/prism/node.rb', line 1889

def each_child_node
  return to_enum(:each_child_node) unless block_given?

end

#inspectObject

def inspect -> String



1929
1930
1931
# File 'lib/prism/node.rb', line 1929

def inspect
  InspectVisitor.compose(self)
end

#repeated_parameter?Boolean

def repeated_parameter?: () -> bool



1918
1919
1920
# File 'lib/prism/node.rb', line 1918

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

#typeObject

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



1934
1935
1936
# File 'lib/prism/node.rb', line 1934

def type
  :block_local_variable_node
end