Class: YARP::MatchPredicateNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents the use of the modifier ‘in` operator.

foo in bar
^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, pattern, operator_loc, location) ⇒ MatchPredicateNode

def initialize: (value: Node, pattern: Node, operator_loc: Location, location: Location) -> void



5169
5170
5171
5172
5173
5174
# File 'lib/yarp/node.rb', line 5169

def initialize(value, pattern, operator_loc, location)
  @value = value
  @pattern = pattern
  @operator_loc = operator_loc
  @location = location
end

Instance Attribute Details

#operator_locObject (readonly)

attr_reader operator_loc: Location



5166
5167
5168
# File 'lib/yarp/node.rb', line 5166

def operator_loc
  @operator_loc
end

#patternObject (readonly)

attr_reader pattern: Node



5163
5164
5165
# File 'lib/yarp/node.rb', line 5163

def pattern
  @pattern
end

#valueObject (readonly)

attr_reader value: Node



5160
5161
5162
# File 'lib/yarp/node.rb', line 5160

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



5177
5178
5179
# File 'lib/yarp/node.rb', line 5177

def accept(visitor)
  visitor.visit_match_predicate_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



5182
5183
5184
# File 'lib/yarp/node.rb', line 5182

def child_nodes
  [value, pattern]
end

#copy(**params) ⇒ Object

def copy: (**params) -> MatchPredicateNode



5187
5188
5189
5190
5191
5192
5193
5194
# File 'lib/yarp/node.rb', line 5187

def copy(**params)
  MatchPredicateNode.new(
    params.fetch(:value) { value },
    params.fetch(:pattern) { pattern },
    params.fetch(:operator_loc) { operator_loc },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



5200
5201
5202
# File 'lib/yarp/node.rb', line 5200

def deconstruct_keys(keys)
  { value: value, pattern: pattern, operator_loc: operator_loc, location: location }
end

#operatorObject

def operator: () -> String



5205
5206
5207
# File 'lib/yarp/node.rb', line 5205

def operator
  operator_loc.slice
end