Class: YARP::OrNode

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

Overview

Represents the use of the ‘||` operator or the `or` keyword.

left or right
^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, right, operator_loc, location) ⇒ OrNode

def initialize: (left: Node, right: Node, operator_loc: Location, location: Location) -> void



4528
4529
4530
4531
4532
4533
# File 'lib/yarp/node.rb', line 4528

def initialize(left, right, operator_loc, location)
  @left = left
  @right = right
  @operator_loc = operator_loc
  @location = location
end

Instance Attribute Details

#leftObject (readonly)

attr_reader left: Node



4519
4520
4521
# File 'lib/yarp/node.rb', line 4519

def left
  @left
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



4525
4526
4527
# File 'lib/yarp/node.rb', line 4525

def operator_loc
  @operator_loc
end

#rightObject (readonly)

attr_reader right: Node



4522
4523
4524
# File 'lib/yarp/node.rb', line 4522

def right
  @right
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4536
4537
4538
# File 'lib/yarp/node.rb', line 4536

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

#child_nodesObject Also known as: deconstruct

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



4541
4542
4543
# File 'lib/yarp/node.rb', line 4541

def child_nodes
  [left, right]
end

#deconstruct_keys(keys) ⇒ Object

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



4549
4550
4551
# File 'lib/yarp/node.rb', line 4549

def deconstruct_keys(keys)
  { left: left, right: right, operator_loc: operator_loc, location: location }
end

#operatorObject

def operator: () -> String



4554
4555
4556
# File 'lib/yarp/node.rb', line 4554

def operator
  operator_loc.slice
end