Class: YARP::RangeNode

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

Overview

Represents the use of the ‘..` or `…` operators.

1..2
^^^^

c if a =~ /left/ ... b =~ /right/
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, right, operator_loc, flags, location) ⇒ RangeNode

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



4936
4937
4938
4939
4940
4941
4942
# File 'lib/yarp/node.rb', line 4936

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

Instance Attribute Details

#flagsObject (readonly)

attr_reader flags: Integer



4933
4934
4935
# File 'lib/yarp/node.rb', line 4933

def flags
  @flags
end

#leftObject (readonly)

attr_reader left: Node?



4924
4925
4926
# File 'lib/yarp/node.rb', line 4924

def left
  @left
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



4930
4931
4932
# File 'lib/yarp/node.rb', line 4930

def operator_loc
  @operator_loc
end

#rightObject (readonly)

attr_reader right: Node?



4927
4928
4929
# File 'lib/yarp/node.rb', line 4927

def right
  @right
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4945
4946
4947
# File 'lib/yarp/node.rb', line 4945

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

#child_nodesObject Also known as: deconstruct

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



4951
4952
4953
# File 'lib/yarp/node.rb', line 4951

def child_nodes
  [left, right]
end

#deconstruct_keys(keys) ⇒ Object

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



4959
4960
4961
# File 'lib/yarp/node.rb', line 4959

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

#operatorObject

def operator: () -> String



4964
4965
4966
# File 'lib/yarp/node.rb', line 4964

def operator
  operator_loc.slice
end