Class: YARP::ClassNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ClassNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a class declaration involving the ‘class` keyword.
class Foo end
^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#class_keyword_loc ⇒ Object
readonly
attr_reader class_keyword_loc: Location.
-
#constant_path ⇒ Object
readonly
attr_reader constant_path: Node.
-
#end_keyword_loc ⇒ Object
readonly
attr_reader end_keyword_loc: Location.
-
#inheritance_operator_loc ⇒ Object
readonly
attr_reader inheritance_operator_loc: Location?.
-
#locals ⇒ Object
readonly
attr_reader locals: Array.
-
#statements ⇒ Object
readonly
attr_reader statements: Node?.
-
#superclass ⇒ Object
readonly
attr_reader superclass: Node?.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#class_keyword ⇒ Object
def class_keyword: () -> String.
- #deconstruct_keys(keys) ⇒ Object
-
#end_keyword ⇒ Object
def end_keyword: () -> String.
-
#inheritance_operator ⇒ Object
def inheritance_operator: () -> String?.
-
#initialize(locals, class_keyword_loc, constant_path, inheritance_operator_loc, superclass, statements, end_keyword_loc, location) ⇒ ClassNode
constructor
def initialize: (locals: Array, class_keyword_loc: Location, constant_path: Node, inheritance_operator_loc: Location?, superclass: Node?, statements: Node?, end_keyword_loc: Location, location: Location) -> void.
Constructor Details
#initialize(locals, class_keyword_loc, constant_path, inheritance_operator_loc, superclass, statements, end_keyword_loc, location) ⇒ ClassNode
def initialize: (locals: Array, class_keyword_loc: Location, constant_path: Node, inheritance_operator_loc: Location?, superclass: Node?, statements: Node?, end_keyword_loc: Location, location: Location) -> void
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 |
# File 'lib/yarp/node.rb', line 1139 def initialize(locals, class_keyword_loc, constant_path, inheritance_operator_loc, superclass, statements, end_keyword_loc, location) @locals = locals @class_keyword_loc = class_keyword_loc @constant_path = constant_path @inheritance_operator_loc = inheritance_operator_loc @superclass = superclass @statements = statements @end_keyword_loc = end_keyword_loc @location = location end |
Instance Attribute Details
#class_keyword_loc ⇒ Object (readonly)
attr_reader class_keyword_loc: Location
1121 1122 1123 |
# File 'lib/yarp/node.rb', line 1121 def class_keyword_loc @class_keyword_loc end |
#constant_path ⇒ Object (readonly)
attr_reader constant_path: Node
1124 1125 1126 |
# File 'lib/yarp/node.rb', line 1124 def constant_path @constant_path end |
#end_keyword_loc ⇒ Object (readonly)
attr_reader end_keyword_loc: Location
1136 1137 1138 |
# File 'lib/yarp/node.rb', line 1136 def end_keyword_loc @end_keyword_loc end |
#inheritance_operator_loc ⇒ Object (readonly)
attr_reader inheritance_operator_loc: Location?
1127 1128 1129 |
# File 'lib/yarp/node.rb', line 1127 def inheritance_operator_loc @inheritance_operator_loc end |
#locals ⇒ Object (readonly)
attr_reader locals: Array
1118 1119 1120 |
# File 'lib/yarp/node.rb', line 1118 def locals @locals end |
#statements ⇒ Object (readonly)
attr_reader statements: Node?
1133 1134 1135 |
# File 'lib/yarp/node.rb', line 1133 def statements @statements end |
#superclass ⇒ Object (readonly)
attr_reader superclass: Node?
1130 1131 1132 |
# File 'lib/yarp/node.rb', line 1130 def superclass @superclass end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
1151 1152 1153 |
# File 'lib/yarp/node.rb', line 1151 def accept(visitor) visitor.visit_class_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1157 1158 1159 |
# File 'lib/yarp/node.rb', line 1157 def child_nodes [constant_path, superclass, statements] end |
#class_keyword ⇒ Object
def class_keyword: () -> String
1170 1171 1172 |
# File 'lib/yarp/node.rb', line 1170 def class_keyword class_keyword_loc.slice end |
#deconstruct_keys(keys) ⇒ Object
1165 1166 1167 |
# File 'lib/yarp/node.rb', line 1165 def deconstruct_keys(keys) { locals: locals, class_keyword_loc: class_keyword_loc, constant_path: constant_path, inheritance_operator_loc: inheritance_operator_loc, superclass: superclass, statements: statements, end_keyword_loc: end_keyword_loc, location: location } end |
#end_keyword ⇒ Object
def end_keyword: () -> String
1180 1181 1182 |
# File 'lib/yarp/node.rb', line 1180 def end_keyword end_keyword_loc.slice end |
#inheritance_operator ⇒ Object
def inheritance_operator: () -> String?
1175 1176 1177 |
# File 'lib/yarp/node.rb', line 1175 def inheritance_operator inheritance_operator_loc&.slice end |