Class: YARP::SingletonClassNode

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

Overview

Represents a singleton class declaration involving the ‘class` keyword.

class << self end
^^^^^^^^^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locals, class_keyword_loc, operator_loc, expression, statements, end_keyword_loc, location) ⇒ SingletonClassNode

def initialize: (locals: Array, class_keyword_loc: Location, operator_loc: Location, expression: Node, statements: Node?, end_keyword_loc: Location, location: Location) -> void



5482
5483
5484
5485
5486
5487
5488
5489
5490
# File 'lib/yarp/node.rb', line 5482

def initialize(locals, class_keyword_loc, operator_loc, expression, statements, end_keyword_loc, location)
  @locals = locals
  @class_keyword_loc = class_keyword_loc
  @operator_loc = operator_loc
  @expression = expression
  @statements = statements
  @end_keyword_loc = end_keyword_loc
  @location = location
end

Instance Attribute Details

#class_keyword_locObject (readonly)

attr_reader class_keyword_loc: Location



5467
5468
5469
# File 'lib/yarp/node.rb', line 5467

def class_keyword_loc
  @class_keyword_loc
end

#end_keyword_locObject (readonly)

attr_reader end_keyword_loc: Location



5479
5480
5481
# File 'lib/yarp/node.rb', line 5479

def end_keyword_loc
  @end_keyword_loc
end

#expressionObject (readonly)

attr_reader expression: Node



5473
5474
5475
# File 'lib/yarp/node.rb', line 5473

def expression
  @expression
end

#localsObject (readonly)

attr_reader locals: Array



5464
5465
5466
# File 'lib/yarp/node.rb', line 5464

def locals
  @locals
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



5470
5471
5472
# File 'lib/yarp/node.rb', line 5470

def operator_loc
  @operator_loc
end

#statementsObject (readonly)

attr_reader statements: Node?



5476
5477
5478
# File 'lib/yarp/node.rb', line 5476

def statements
  @statements
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



5493
5494
5495
# File 'lib/yarp/node.rb', line 5493

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

#child_nodesObject Also known as: deconstruct

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



5499
5500
5501
# File 'lib/yarp/node.rb', line 5499

def child_nodes
  [expression, statements]
end

#class_keywordObject

def class_keyword: () -> String



5512
5513
5514
# File 'lib/yarp/node.rb', line 5512

def class_keyword
  class_keyword_loc.slice
end

#deconstruct_keys(keys) ⇒ Object

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



5507
5508
5509
# File 'lib/yarp/node.rb', line 5507

def deconstruct_keys(keys)
  { locals: locals, class_keyword_loc: class_keyword_loc, operator_loc: operator_loc, expression: expression, statements: statements, end_keyword_loc: end_keyword_loc, location: location }
end

#end_keywordObject

def end_keyword: () -> String



5522
5523
5524
# File 'lib/yarp/node.rb', line 5522

def end_keyword
  end_keyword_loc.slice
end

#operatorObject

def operator: () -> String



5517
5518
5519
# File 'lib/yarp/node.rb', line 5517

def operator
  operator_loc.slice
end