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



4082
4083
4084
4085
4086
4087
# File 'lib/yarp/node.rb', line 4082

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



4079
4080
4081
# File 'lib/yarp/node.rb', line 4079

def operator_loc
  @operator_loc
end

#patternObject (readonly)

attr_reader pattern: Node



4076
4077
4078
# File 'lib/yarp/node.rb', line 4076

def pattern
  @pattern
end

#valueObject (readonly)

attr_reader value: Node



4073
4074
4075
# File 'lib/yarp/node.rb', line 4073

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4090
4091
4092
# File 'lib/yarp/node.rb', line 4090

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

#child_nodesObject Also known as: deconstruct

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



4095
4096
4097
# File 'lib/yarp/node.rb', line 4095

def child_nodes
  [value, pattern]
end

#deconstruct_keys(keys) ⇒ Object

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



4103
4104
4105
# File 'lib/yarp/node.rb', line 4103

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

#operatorObject

def operator: () -> String



4108
4109
4110
# File 'lib/yarp/node.rb', line 4108

def operator
  operator_loc.slice
end