Class: YARP::YieldNode

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

Overview

Represents the use of the ‘yield` keyword.

yield 1
^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keyword_loc, lparen_loc, arguments, rparen_loc, location) ⇒ YieldNode

def initialize: (keyword_loc: Location, lparen_loc: Location?, arguments: Node?, rparen_loc: Location?, location: Location) -> void



6315
6316
6317
6318
6319
6320
6321
# File 'lib/yarp/node.rb', line 6315

def initialize(keyword_loc, lparen_loc, arguments, rparen_loc, location)
  @keyword_loc = keyword_loc
  @lparen_loc = lparen_loc
  @arguments = arguments
  @rparen_loc = rparen_loc
  @location = location
end

Instance Attribute Details

#argumentsObject (readonly)

attr_reader arguments: Node?



6309
6310
6311
# File 'lib/yarp/node.rb', line 6309

def arguments
  @arguments
end

#keyword_locObject (readonly)

attr_reader keyword_loc: Location



6303
6304
6305
# File 'lib/yarp/node.rb', line 6303

def keyword_loc
  @keyword_loc
end

#lparen_locObject (readonly)

attr_reader lparen_loc: Location?



6306
6307
6308
# File 'lib/yarp/node.rb', line 6306

def lparen_loc
  @lparen_loc
end

#rparen_locObject (readonly)

attr_reader rparen_loc: Location?



6312
6313
6314
# File 'lib/yarp/node.rb', line 6312

def rparen_loc
  @rparen_loc
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



6324
6325
6326
# File 'lib/yarp/node.rb', line 6324

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

#child_nodesObject Also known as: deconstruct

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



6330
6331
6332
# File 'lib/yarp/node.rb', line 6330

def child_nodes
  [arguments]
end

#deconstruct_keys(keys) ⇒ Object

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



6338
6339
6340
# File 'lib/yarp/node.rb', line 6338

def deconstruct_keys(keys)
  { keyword_loc: keyword_loc, lparen_loc: lparen_loc, arguments: arguments, rparen_loc: rparen_loc, location: location }
end

#keywordObject

def keyword: () -> String



6343
6344
6345
# File 'lib/yarp/node.rb', line 6343

def keyword
  keyword_loc.slice
end

#lparenObject

def lparen: () -> String?



6348
6349
6350
# File 'lib/yarp/node.rb', line 6348

def lparen
  lparen_loc&.slice
end

#rparenObject

def rparen: () -> String?



6353
6354
6355
# File 'lib/yarp/node.rb', line 6353

def rparen
  rparen_loc&.slice
end