Class: YARP::MatchRequiredNode

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

Overview

Represents the use of the ‘=>` operator.

foo => bar
^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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



4097
4098
4099
4100
4101
4102
# File 'lib/yarp/node.rb', line 4097

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



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

def operator_loc
  @operator_loc
end

#patternObject (readonly)

attr_reader pattern: Node



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

def pattern
  @pattern
end

#valueObject (readonly)

attr_reader value: Node



4088
4089
4090
# File 'lib/yarp/node.rb', line 4088

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4105
4106
4107
# File 'lib/yarp/node.rb', line 4105

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

#child_nodesObject Also known as: deconstruct

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



4111
4112
4113
# File 'lib/yarp/node.rb', line 4111

def child_nodes
  [value, pattern]
end

#deconstruct_keys(keys) ⇒ Object

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



4119
4120
4121
# File 'lib/yarp/node.rb', line 4119

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

#operatorObject

def operator: () -> String



4124
4125
4126
# File 'lib/yarp/node.rb', line 4124

def operator
  operator_loc.slice
end