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



4506
4507
4508
4509
4510
4511
# File 'lib/yarp/node.rb', line 4506

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



4497
4498
4499
# File 'lib/yarp/node.rb', line 4497

def left
  @left
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



4503
4504
4505
# File 'lib/yarp/node.rb', line 4503

def operator_loc
  @operator_loc
end

#rightObject (readonly)

attr_reader right: Node



4500
4501
4502
# File 'lib/yarp/node.rb', line 4500

def right
  @right
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4514
4515
4516
# File 'lib/yarp/node.rb', line 4514

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

#child_nodesObject Also known as: deconstruct

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



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

def child_nodes
  [left, right]
end

#deconstruct_keys(keys) ⇒ Object

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



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

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

#operatorObject

def operator: () -> String



4533
4534
4535
# File 'lib/yarp/node.rb', line 4533

def operator
  operator_loc.slice
end