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 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) -> MatchPredicateNode.
-
#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) ⇒ 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.
-
#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.
11257 11258 11259 11260 11261 11262 11263 11264 11265 |
# File 'lib/prism/node.rb', line 11257 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
11304 11305 11306 |
# File 'lib/prism/node.rb', line 11304 def pattern @pattern end |
#value ⇒ Object (readonly)
attr_reader value: Prism::node
11301 11302 11303 |
# File 'lib/prism/node.rb', line 11301 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
11329 11330 11331 |
# File 'lib/prism/node.rb', line 11329 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.
11335 11336 11337 11338 11339 11340 |
# File 'lib/prism/node.rb', line 11335 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
11268 11269 11270 |
# File 'lib/prism/node.rb', line 11268 def accept(visitor) visitor.visit_match_predicate_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
11273 11274 11275 |
# File 'lib/prism/node.rb', line 11273 def child_nodes [value, pattern] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
11283 11284 11285 |
# File 'lib/prism/node.rb', line 11283 def comment_targets [value, pattern, operator_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
11278 11279 11280 |
# File 'lib/prism/node.rb', line 11278 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
11288 11289 11290 |
# File 'lib/prism/node.rb', line 11288 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 }
11296 11297 11298 |
# File 'lib/prism/node.rb', line 11296 def deconstruct_keys(keys) { node_id: node_id, location: location, value: value, pattern: pattern, operator_loc: operator_loc } end |
#inspect ⇒ Object
def inspect -> String
11319 11320 11321 |
# File 'lib/prism/node.rb', line 11319 def inspect InspectVisitor.compose(self) end |
#operator ⇒ Object
def operator: () -> String
11314 11315 11316 |
# File 'lib/prism/node.rb', line 11314 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
11307 11308 11309 11310 11311 |
# File 'lib/prism/node.rb', line 11307 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`.
11324 11325 11326 |
# File 'lib/prism/node.rb', line 11324 def type :match_predicate_node end |