Class: Prism::MatchPredicateNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::MatchPredicateNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents the use of the modifier in operator.
foo in
^^^^^^^^^^
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.
-
#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) -> MatchPredicateNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: Prism::node, pattern: Prism::node, operator_loc: Location }.
-
#each_child_node {|value| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator.
-
#initialize(source, node_id, location, flags, value, pattern, operator_loc) ⇒ MatchPredicateNode
constructor
Initialize a new MatchPredicateNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#operator ⇒ Object
def operator: () -> String.
-
#operator_loc ⇒ Object
attr_reader operator_loc: Location.
-
#save_operator_loc(repository) ⇒ Object
Save the operator_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, value, pattern, operator_loc) ⇒ MatchPredicateNode
Initialize a new MatchPredicateNode node.
13421 13422 13423 13424 13425 13426 13427 13428 13429 |
# File 'lib/prism/node.rb', line 13421 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
13476 13477 13478 |
# File 'lib/prism/node.rb', line 13476 def pattern @pattern end |
#value ⇒ Object (readonly)
attr_reader value: Prism::node
13473 13474 13475 |
# File 'lib/prism/node.rb', line 13473 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See Node::type.
13507 13508 13509 |
# File 'lib/prism/node.rb', line 13507 def self.type :match_predicate_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.
13513 13514 13515 13516 13517 13518 |
# File 'lib/prism/node.rb', line 13513 def ===(other) other.is_a?(MatchPredicateNode) && (value === other.value) && (pattern === other.pattern) && (operator_loc.nil? == other.operator_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
13432 13433 13434 |
# File 'lib/prism/node.rb', line 13432 def accept(visitor) visitor.visit_match_predicate_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
13437 13438 13439 |
# File 'lib/prism/node.rb', line 13437 def child_nodes [value, pattern] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
13455 13456 13457 |
# File 'lib/prism/node.rb', line 13455 def comment_targets [value, pattern, operator_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
13450 13451 13452 |
# File 'lib/prism/node.rb', line 13450 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) -> MatchPredicateNode
13460 13461 13462 |
# File 'lib/prism/node.rb', line 13460 def copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value, pattern: self.pattern, operator_loc: self.operator_loc) MatchPredicateNode.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 }
13468 13469 13470 |
# File 'lib/prism/node.rb', line 13468 def deconstruct_keys(keys) { node_id: node_id, location: location, value: value, pattern: pattern, operator_loc: operator_loc } end |
#each_child_node {|value| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator
13442 13443 13444 13445 13446 13447 |
# File 'lib/prism/node.rb', line 13442 def each_child_node return to_enum(:each_child_node) unless block_given? yield value yield pattern end |
#inspect ⇒ Object
def inspect -> String
13497 13498 13499 |
# File 'lib/prism/node.rb', line 13497 def inspect InspectVisitor.compose(self) end |
#operator ⇒ Object
def operator: () -> String
13492 13493 13494 |
# File 'lib/prism/node.rb', line 13492 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
13479 13480 13481 13482 13483 |
# File 'lib/prism/node.rb', line 13479 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_operator_loc(repository) ⇒ Object
Save the operator_loc location using the given saved source so that it can be retrieved later.
13487 13488 13489 |
# File 'lib/prism/node.rb', line 13487 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
13502 13503 13504 |
# File 'lib/prism/node.rb', line 13502 def type :match_predicate_node end |