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



5531
5532
5533
5534
5535
5536
5537
5538
5539
# File 'lib/yarp/node.rb', line 5531

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



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

def class_keyword_loc
  @class_keyword_loc
end

#end_keyword_locObject (readonly)

attr_reader end_keyword_loc: Location



5528
5529
5530
# File 'lib/yarp/node.rb', line 5528

def end_keyword_loc
  @end_keyword_loc
end

#expressionObject (readonly)

attr_reader expression: Node



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

def expression
  @expression
end

#localsObject (readonly)

attr_reader locals: Array



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

def locals
  @locals
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



5519
5520
5521
# File 'lib/yarp/node.rb', line 5519

def operator_loc
  @operator_loc
end

#statementsObject (readonly)

attr_reader statements: Node?



5525
5526
5527
# File 'lib/yarp/node.rb', line 5525

def statements
  @statements
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



5542
5543
5544
# File 'lib/yarp/node.rb', line 5542

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

#child_nodesObject Also known as: deconstruct

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



5547
5548
5549
# File 'lib/yarp/node.rb', line 5547

def child_nodes
  [expression, statements]
end

#class_keywordObject

def class_keyword: () -> String



5560
5561
5562
# File 'lib/yarp/node.rb', line 5560

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]



5555
5556
5557
# File 'lib/yarp/node.rb', line 5555

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



5570
5571
5572
# File 'lib/yarp/node.rb', line 5570

def end_keyword
  end_keyword_loc.slice
end

#operatorObject

def operator: () -> String



5565
5566
5567
# File 'lib/yarp/node.rb', line 5565

def operator
  operator_loc.slice
end