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



4050
4051
4052
4053
4054
4055
# File 'lib/yarp/node.rb', line 4050

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



4047
4048
4049
# File 'lib/yarp/node.rb', line 4047

def operator_loc
  @operator_loc
end

#patternObject (readonly)

attr_reader pattern: Node



4044
4045
4046
# File 'lib/yarp/node.rb', line 4044

def pattern
  @pattern
end

#valueObject (readonly)

attr_reader value: Node



4041
4042
4043
# File 'lib/yarp/node.rb', line 4041

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4058
4059
4060
# File 'lib/yarp/node.rb', line 4058

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

#child_nodesObject Also known as: deconstruct

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



4064
4065
4066
# File 'lib/yarp/node.rb', line 4064

def child_nodes
  [value, pattern]
end

#deconstruct_keys(keys) ⇒ Object

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



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

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

#operatorObject

def operator: () -> String



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

def operator
  operator_loc.slice
end