Class: Prism::MatchRequiredNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::MatchRequiredNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents the use of the ‘=>` operator.
foo => bar
^^^^^^^^^^
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
attr_reader pattern: Prism::node.
-
#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, pattern: self.pattern, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?operator_loc: Location) -> MatchRequiredNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: Prism::node, pattern: Prism::node, operator_loc: Location }.
-
#initialize(source, node_id, location, flags, value, pattern, operator_loc) ⇒ MatchRequiredNode
constructor
Initialize a new MatchRequiredNode 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, pattern, operator_loc) ⇒ MatchRequiredNode
Initialize a new MatchRequiredNode node.
11349 11350 11351 11352 11353 11354 11355 11356 11357 |
# File 'lib/prism/node.rb', line 11349 def initialize(source, node_id, location, flags, value, pattern, operator_loc) @source = source @node_id = node_id @location = location @flags = flags @value = value @pattern = pattern @operator_loc = operator_loc end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
attr_reader pattern: Prism::node
11396 11397 11398 |
# File 'lib/prism/node.rb', line 11396 def pattern @pattern end |
#value ⇒ Object (readonly)
attr_reader value: Prism::node
11393 11394 11395 |
# File 'lib/prism/node.rb', line 11393 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
11421 11422 11423 |
# File 'lib/prism/node.rb', line 11421 def self.type :match_required_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.
11427 11428 11429 11430 11431 11432 |
# File 'lib/prism/node.rb', line 11427 def ===(other) other.is_a?(MatchRequiredNode) && (value === other.value) && (pattern === other.pattern) && (operator_loc.nil? == other.operator_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
11360 11361 11362 |
# File 'lib/prism/node.rb', line 11360 def accept(visitor) visitor.visit_match_required_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
11365 11366 11367 |
# File 'lib/prism/node.rb', line 11365 def child_nodes [value, pattern] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
11375 11376 11377 |
# File 'lib/prism/node.rb', line 11375 def comment_targets [value, pattern, operator_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
11370 11371 11372 |
# File 'lib/prism/node.rb', line 11370 def compact_child_nodes [value, pattern] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value, pattern: self.pattern, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?operator_loc: Location) -> MatchRequiredNode
11380 11381 11382 |
# File 'lib/prism/node.rb', line 11380 def copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value, pattern: self.pattern, operator_loc: self.operator_loc) MatchRequiredNode.new(source, node_id, location, flags, value, pattern, operator_loc) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: Prism::node, pattern: Prism::node, operator_loc: Location }
11388 11389 11390 |
# File 'lib/prism/node.rb', line 11388 def deconstruct_keys(keys) { node_id: node_id, location: location, value: value, pattern: pattern, operator_loc: operator_loc } end |
#inspect ⇒ Object
def inspect -> String
11411 11412 11413 |
# File 'lib/prism/node.rb', line 11411 def inspect InspectVisitor.compose(self) end |
#operator ⇒ Object
def operator: () -> String
11406 11407 11408 |
# File 'lib/prism/node.rb', line 11406 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
11399 11400 11401 11402 11403 |
# File 'lib/prism/node.rb', line 11399 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`.
11416 11417 11418 |
# File 'lib/prism/node.rb', line 11416 def type :match_required_node end |