Class: Prism::BlockParameterNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::BlockParameterNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents a block parameter of a method, block, or lambda definition.
def a(&b)
^^
end
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
attr_reader name: Symbol?.
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, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> BlockParameterNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol?, name_loc: Location?, operator_loc: Location }.
-
#initialize(source, node_id, location, flags, name, name_loc, operator_loc) ⇒ BlockParameterNode
constructor
Initialize a new BlockParameterNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#name_loc ⇒ Object
attr_reader name_loc: Location?.
-
#operator ⇒ Object
def operator: () -> String.
-
#operator_loc ⇒ Object
attr_reader operator_loc: Location.
-
#repeated_parameter? ⇒ Boolean
def repeated_parameter?: () -> bool.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, name, name_loc, operator_loc) ⇒ BlockParameterNode
Initialize a new BlockParameterNode node.
1695 1696 1697 1698 1699 1700 1701 1702 1703 |
# File 'lib/prism/node.rb', line 1695 def initialize(source, node_id, location, flags, name, name_loc, operator_loc) @source = source @node_id = node_id @location = location @flags = flags @name = name @name_loc = name_loc @operator_loc = operator_loc end |
Instance Attribute Details
#name ⇒ Object (readonly)
attr_reader name: Symbol?
1744 1745 1746 |
# File 'lib/prism/node.rb', line 1744 def name @name end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
1782 1783 1784 |
# File 'lib/prism/node.rb', line 1782 def self.type :block_parameter_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.
1788 1789 1790 1791 1792 1793 1794 |
# File 'lib/prism/node.rb', line 1788 def ===(other) other.is_a?(BlockParameterNode) && (flags === other.flags) && (name === other.name) && (name_loc.nil? == other.name_loc.nil?) && (operator_loc.nil? == other.operator_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
1706 1707 1708 |
# File 'lib/prism/node.rb', line 1706 def accept(visitor) visitor.visit_block_parameter_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1711 1712 1713 |
# File 'lib/prism/node.rb', line 1711 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
1721 1722 1723 |
# File 'lib/prism/node.rb', line 1721 def comment_targets [*name_loc, operator_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
1716 1717 1718 |
# File 'lib/prism/node.rb', line 1716 def compact_child_nodes [] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> BlockParameterNode
1726 1727 1728 |
# File 'lib/prism/node.rb', line 1726 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc) BlockParameterNode.new(source, node_id, location, flags, name, name_loc, operator_loc) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol?, name_loc: Location?, operator_loc: Location }
1734 1735 1736 |
# File 'lib/prism/node.rb', line 1734 def deconstruct_keys(keys) { node_id: node_id, location: location, name: name, name_loc: name_loc, operator_loc: operator_loc } end |
#inspect ⇒ Object
def inspect -> String
1772 1773 1774 |
# File 'lib/prism/node.rb', line 1772 def inspect InspectVisitor.compose(self) end |
#name_loc ⇒ Object
attr_reader name_loc: Location?
1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 |
# File 'lib/prism/node.rb', line 1747 def name_loc location = @name_loc case location when nil nil when Location location else @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end |
#operator ⇒ Object
def operator: () -> String
1767 1768 1769 |
# File 'lib/prism/node.rb', line 1767 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
1760 1761 1762 1763 1764 |
# File 'lib/prism/node.rb', line 1760 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#repeated_parameter? ⇒ Boolean
def repeated_parameter?: () -> bool
1739 1740 1741 |
# File 'lib/prism/node.rb', line 1739 def repeated_parameter? flags.anybits?(ParameterFlags::REPEATED_PARAMETER) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
1777 1778 1779 |
# File 'lib/prism/node.rb', line 1777 def type :block_parameter_node end |