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



4951
4952
4953
4954
4955
4956
4957
# File 'lib/yarp/node.rb', line 4951

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



4948
4949
4950
# File 'lib/yarp/node.rb', line 4948

def flags
  @flags
end

#leftObject (readonly)

attr_reader left: Node?



4939
4940
4941
# File 'lib/yarp/node.rb', line 4939

def left
  @left
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



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

def operator_loc
  @operator_loc
end

#rightObject (readonly)

attr_reader right: Node?



4942
4943
4944
# File 'lib/yarp/node.rb', line 4942

def right
  @right
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



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

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

#child_nodesObject Also known as: deconstruct

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



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

def child_nodes
  [left, right]
end

#deconstruct_keys(keys) ⇒ Object

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



4973
4974
4975
# File 'lib/yarp/node.rb', line 4973

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

#exclude_end?Boolean

def exclude_end?: () -> bool

Returns:

  • (Boolean)


4983
4984
4985
# File 'lib/yarp/node.rb', line 4983

def exclude_end?
  flags.anybits?(RangeFlags::EXCLUDE_END)
end

#operatorObject

def operator: () -> String



4978
4979
4980
# File 'lib/yarp/node.rb', line 4978

def operator
  operator_loc.slice
end