Class: YARP::FlipFlopNode

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

Overview

Represents the use of the ‘..` or `…` operators to create flip flops.

baz if foo .. bar
       ^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

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



2357
2358
2359
2360
2361
2362
2363
# File 'lib/yarp/node.rb', line 2357

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



2354
2355
2356
# File 'lib/yarp/node.rb', line 2354

def flags
  @flags
end

#leftObject (readonly)

attr_reader left: Node?



2345
2346
2347
# File 'lib/yarp/node.rb', line 2345

def left
  @left
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



2351
2352
2353
# File 'lib/yarp/node.rb', line 2351

def operator_loc
  @operator_loc
end

#rightObject (readonly)

attr_reader right: Node?



2348
2349
2350
# File 'lib/yarp/node.rb', line 2348

def right
  @right
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



2366
2367
2368
# File 'lib/yarp/node.rb', line 2366

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

#child_nodesObject Also known as: deconstruct

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



2371
2372
2373
# File 'lib/yarp/node.rb', line 2371

def child_nodes
  [left, right]
end

#deconstruct_keys(keys) ⇒ Object

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



2379
2380
2381
# File 'lib/yarp/node.rb', line 2379

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)


2389
2390
2391
# File 'lib/yarp/node.rb', line 2389

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

#operatorObject

def operator: () -> String



2384
2385
2386
# File 'lib/yarp/node.rb', line 2384

def operator
  operator_loc.slice
end