Class: YARP::ModuleNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ModuleNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a module declaration involving the ‘module` keyword.
module Foo end
^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
attr_reader body: Node?.
-
#constant_path ⇒ Object
readonly
attr_reader constant_path: Node.
-
#end_keyword_loc ⇒ Object
readonly
attr_reader end_keyword_loc: Location.
-
#locals ⇒ Object
readonly
attr_reader locals: Array.
-
#module_keyword_loc ⇒ Object
readonly
attr_reader module_keyword_loc: Location.
-
#name ⇒ Object
readonly
attr_reader name: String.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#copy(**params) ⇒ Object
def copy: (**params) -> ModuleNode.
- #deconstruct_keys(keys) ⇒ Object
-
#end_keyword ⇒ Object
def end_keyword: () -> String.
-
#initialize(locals, module_keyword_loc, constant_path, body, end_keyword_loc, name, location) ⇒ ModuleNode
constructor
def initialize: (locals: Array, module_keyword_loc: Location, constant_path: Node, body: Node?, end_keyword_loc: Location, name: String, location: Location) -> void.
-
#module_keyword ⇒ Object
def module_keyword: () -> String.
Constructor Details
#initialize(locals, module_keyword_loc, constant_path, body, end_keyword_loc, name, location) ⇒ ModuleNode
def initialize: (locals: Array, module_keyword_loc: Location, constant_path: Node, body: Node?, end_keyword_loc: Location, name: String, location: Location) -> void
5324 5325 5326 5327 5328 5329 5330 5331 5332 |
# File 'lib/yarp/node.rb', line 5324 def initialize(locals, module_keyword_loc, constant_path, body, end_keyword_loc, name, location) @locals = locals @module_keyword_loc = module_keyword_loc @constant_path = constant_path @body = body @end_keyword_loc = end_keyword_loc @name = name @location = location end |
Instance Attribute Details
#body ⇒ Object (readonly)
attr_reader body: Node?
5315 5316 5317 |
# File 'lib/yarp/node.rb', line 5315 def body @body end |
#constant_path ⇒ Object (readonly)
attr_reader constant_path: Node
5312 5313 5314 |
# File 'lib/yarp/node.rb', line 5312 def constant_path @constant_path end |
#end_keyword_loc ⇒ Object (readonly)
attr_reader end_keyword_loc: Location
5318 5319 5320 |
# File 'lib/yarp/node.rb', line 5318 def end_keyword_loc @end_keyword_loc end |
#locals ⇒ Object (readonly)
attr_reader locals: Array
5306 5307 5308 |
# File 'lib/yarp/node.rb', line 5306 def locals @locals end |
#module_keyword_loc ⇒ Object (readonly)
attr_reader module_keyword_loc: Location
5309 5310 5311 |
# File 'lib/yarp/node.rb', line 5309 def module_keyword_loc @module_keyword_loc end |
#name ⇒ Object (readonly)
attr_reader name: String
5321 5322 5323 |
# File 'lib/yarp/node.rb', line 5321 def name @name end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
5335 5336 5337 |
# File 'lib/yarp/node.rb', line 5335 def accept(visitor) visitor.visit_module_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
5340 5341 5342 |
# File 'lib/yarp/node.rb', line 5340 def child_nodes [constant_path, body] end |
#copy(**params) ⇒ Object
def copy: (**params) -> ModuleNode
5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 |
# File 'lib/yarp/node.rb', line 5345 def copy(**params) ModuleNode.new( params.fetch(:locals) { locals }, params.fetch(:module_keyword_loc) { module_keyword_loc }, params.fetch(:constant_path) { constant_path }, params.fetch(:body) { body }, params.fetch(:end_keyword_loc) { end_keyword_loc }, params.fetch(:name) { name }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
5361 5362 5363 |
# File 'lib/yarp/node.rb', line 5361 def deconstruct_keys(keys) { locals: locals, module_keyword_loc: module_keyword_loc, constant_path: constant_path, body: body, end_keyword_loc: end_keyword_loc, name: name, location: location } end |
#end_keyword ⇒ Object
def end_keyword: () -> String
5371 5372 5373 |
# File 'lib/yarp/node.rb', line 5371 def end_keyword end_keyword_loc.slice end |
#module_keyword ⇒ Object
def module_keyword: () -> String
5366 5367 5368 |
# File 'lib/yarp/node.rb', line 5366 def module_keyword module_keyword_loc.slice end |