Class: Prism::CapturePatternNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::CapturePatternNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents assigning to a local variable in pattern matching.
foo => [bar => baz]
^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
attr_reader target: LocalVariableTargetNode.
-
#value ⇒ Object
readonly
attr_reader value: Prism::node.
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, value: self.value, target: self.target, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?target: LocalVariableTargetNode, ?operator_loc: Location) -> CapturePatternNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: Prism::node, target: LocalVariableTargetNode, operator_loc: Location }.
-
#initialize(source, node_id, location, flags, value, target, operator_loc) ⇒ CapturePatternNode
constructor
Initialize a new CapturePatternNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#operator ⇒ Object
def operator: () -> String.
-
#operator_loc ⇒ Object
attr_reader operator_loc: Location.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, value, target, operator_loc) ⇒ CapturePatternNode
Initialize a new CapturePatternNode node.
2911 2912 2913 2914 2915 2916 2917 2918 2919 |
# File 'lib/prism/node.rb', line 2911 def initialize(source, node_id, location, flags, value, target, operator_loc) @source = source @node_id = node_id @location = location @flags = flags @value = value @target = target @operator_loc = operator_loc end |
Instance Attribute Details
#target ⇒ Object (readonly)
attr_reader target: LocalVariableTargetNode
2958 2959 2960 |
# File 'lib/prism/node.rb', line 2958 def target @target end |
#value ⇒ Object (readonly)
attr_reader value: Prism::node
2955 2956 2957 |
# File 'lib/prism/node.rb', line 2955 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
2983 2984 2985 |
# File 'lib/prism/node.rb', line 2983 def self.type :capture_pattern_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.
2989 2990 2991 2992 2993 2994 |
# File 'lib/prism/node.rb', line 2989 def ===(other) other.is_a?(CapturePatternNode) && (value === other.value) && (target === other.target) && (operator_loc.nil? == other.operator_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
2922 2923 2924 |
# File 'lib/prism/node.rb', line 2922 def accept(visitor) visitor.visit_capture_pattern_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2927 2928 2929 |
# File 'lib/prism/node.rb', line 2927 def child_nodes [value, target] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
2937 2938 2939 |
# File 'lib/prism/node.rb', line 2937 def comment_targets [value, target, operator_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
2932 2933 2934 |
# File 'lib/prism/node.rb', line 2932 def compact_child_nodes [value, target] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value, target: self.target, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?target: LocalVariableTargetNode, ?operator_loc: Location) -> CapturePatternNode
2942 2943 2944 |
# File 'lib/prism/node.rb', line 2942 def copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value, target: self.target, operator_loc: self.operator_loc) CapturePatternNode.new(source, node_id, location, flags, value, target, operator_loc) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: Prism::node, target: LocalVariableTargetNode, operator_loc: Location }
2950 2951 2952 |
# File 'lib/prism/node.rb', line 2950 def deconstruct_keys(keys) { node_id: node_id, location: location, value: value, target: target, operator_loc: operator_loc } end |
#inspect ⇒ Object
def inspect -> String
2973 2974 2975 |
# File 'lib/prism/node.rb', line 2973 def inspect InspectVisitor.compose(self) end |
#operator ⇒ Object
def operator: () -> String
2968 2969 2970 |
# File 'lib/prism/node.rb', line 2968 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
2961 2962 2963 2964 2965 |
# File 'lib/prism/node.rb', line 2961 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
2978 2979 2980 |
# File 'lib/prism/node.rb', line 2978 def type :capture_pattern_node end |