Class: Prism::ModuleNode
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
PrismNode
|
|
|
Instance Chain:
self,
PrismNode
|
|
| Inherits: |
PrismNode
|
| Defined in: | lib/prism/node.rb, ext/prism/api_node.c |
Overview
Represents a module declaration involving the module keyword.
module Foo end
^^^^^^^^^^^^^^
Class Method Summary
-
.new(source, node_id, location, flags, locals, module_keyword_loc, constant_path, body, end_keyword_loc, name) ⇒ ModuleNode
constructor
Initialize a new
ModuleNodenode. -
.type
Return a symbol representation of this node type.
Instance Attribute Summary
-
#body
readonly
attr_reader body:
Prism.node? -
#constant_path
readonly
attr_reader constant_path:
Prism.node -
#locals
readonly
attr_reader locals: Array.
-
#name
readonly
attr_reader name: Symbol.
Instance Method Summary
-
#===(other)
Implements case-equality for the node.
-
#accept(visitor)
def accept: (Visitor visitor) -> void.
-
#child_nodes
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes
def compact_child_nodes: () -> Array.
- #copy(node_id: self.node_id, location: self.location, flags: self.flags, locals: self.locals, module_keyword_loc: self.module_keyword_loc, constant_path: self.constant_path, body: self.body, end_keyword_loc: self.end_keyword_loc, name: self.name)
-
#deconstruct
Alias for #child_nodes.
- #deconstruct_keys(keys)
-
#end_keyword
def end_keyword: () -> String.
-
#end_keyword_loc
attr_reader end_keyword_loc:
Location. -
#inspect
def inspect -> String.
-
#module_keyword
def module_keyword: () -> String.
-
#module_keyword_loc
attr_reader module_keyword_loc:
Location. -
#type
Return a symbol representation of this node type.
Constructor Details
.new(source, node_id, location, flags, locals, module_keyword_loc, constant_path, body, end_keyword_loc, name) ⇒ ModuleNode
Initialize a new ModuleNode node.
# File 'lib/prism/node.rb', line 11340
def initialize(source, node_id, location, flags, locals, module_keyword_loc, constant_path, body, end_keyword_loc, name) @source = source @node_id = node_id @location = location @flags = flags @locals = locals @module_keyword_loc = module_keyword_loc @constant_path = constant_path @body = body @end_keyword_loc = end_keyword_loc @name = name end
Class Method Details
.type
Return a symbol representation of this node type. See Node::type.
# File 'lib/prism/node.rb', line 11432
def self.type :module_node end
Instance Attribute Details
#body (readonly)
attr_reader body: Prism.node?
# File 'lib/prism/node.rb', line 11401
attr_reader :body
#constant_path (readonly)
attr_reader constant_path: Prism.node
# File 'lib/prism/node.rb', line 11399
attr_reader :constant_path
#locals (readonly)
attr_reader locals: Array
# File 'lib/prism/node.rb', line 11390
attr_reader :locals
#name (readonly)
attr_reader name: Symbol
# File 'lib/prism/node.rb', line 11410
attr_reader :name
Instance Method Details
#===(other)
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
# File 'lib/prism/node.rb', line 11438
def ===(other) other.is_a?(ModuleNode) && (locals.length == other.locals.length) && locals.zip(other.locals).all? { |left, right| left === right } && (module_keyword_loc.nil? == other.module_keyword_loc.nil?) && (constant_path === other.constant_path) && (body === other.body) && (end_keyword_loc.nil? == other.end_keyword_loc.nil?) && (name === other.name) end
#accept(visitor)
def accept: (Visitor visitor) -> void
# File 'lib/prism/node.rb', line 11354
def accept(visitor) visitor.visit_module_node(self) end
#child_nodes Also known as: #deconstruct
def child_nodes: () -> Array[nil | Node]
# File 'lib/prism/node.rb', line 11359
def child_nodes [constant_path, body] end
#comment_targets
def comment_targets: () -> Array[Node | Location]
# File 'lib/prism/node.rb', line 11372
def comment_targets [module_keyword_loc, constant_path, *body, end_keyword_loc] #: Array[Prism::node | Location] end
#compact_child_nodes
def compact_child_nodes: () -> Array
# File 'lib/prism/node.rb', line 11364
def compact_child_nodes compact = [] #: Array[Prism::node] compact << constant_path compact << body if body compact end
#copy(node_id: self.node_id, location: self.location, flags: self.flags, locals: self.locals, module_keyword_loc: self.module_keyword_loc, constant_path: self.constant_path, body: self.body, end_keyword_loc: self.end_keyword_loc, name: self.name)
# File 'lib/prism/node.rb', line 11377
def copy(node_id: self.node_id, location: self.location, flags: self.flags, locals: self.locals, module_keyword_loc: self.module_keyword_loc, constant_path: self.constant_path, body: self.body, end_keyword_loc: self.end_keyword_loc, name: self.name) ModuleNode.new(source, node_id, location, flags, locals, module_keyword_loc, constant_path, body, end_keyword_loc, name) end
#deconstruct
Alias for #child_nodes.
# File 'lib/prism/node.rb', line 11382
alias deconstruct child_nodes
#deconstruct_keys(keys)
# File 'lib/prism/node.rb', line 11385
def deconstruct_keys(keys) { node_id: node_id, location: location, locals: locals, module_keyword_loc: module_keyword_loc, constant_path: constant_path, body: body, end_keyword_loc: end_keyword_loc, name: name } end
#end_keyword
def end_keyword: () -> String
# File 'lib/prism/node.rb', line 11417
def end_keyword end_keyword_loc.slice end
#end_keyword_loc
attr_reader end_keyword_loc: Location
#inspect
def inspect -> String
# File 'lib/prism/node.rb', line 11422
def inspect InspectVisitor.compose(self) end
#module_keyword
def module_keyword: () -> String
# File 'lib/prism/node.rb', line 11412
def module_keyword module_keyword_loc.slice end
#module_keyword_loc
attr_reader module_keyword_loc: Location
#type
Return a symbol representation of this node type. See Node#type.
# File 'lib/prism/node.rb', line 11427
def type :module_node end