class Prism::ModuleNode
Represents a module declaration involving the module keyword.
module Foo end ^^^^^^^^^^^^^^
Public Class Methods
Source
# File lib/prism/node.rb, line 21925 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
Initialize a new ModuleNode node.
Public Instance Methods
Source
# File lib/prism/node.rb, line 22077 def body @body end
Returns the body attribute.
Source
# File lib/prism/node.rb, line 22067 def constant_path @constant_path end
Returns the constant_path attribute.
Source
# File lib/prism/node.rb, line 22035 def locals @locals end
Returns the locals attribute.
Source
# File lib/prism/node.rb, line 22109 def name @name end
Returns the name attribute.
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 22088 def end_keyword_loc location = @end_keyword_loc return location if location.is_a?(Location) @end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by end_keyword_loc.
Source
# File lib/prism/node.rb, line 22046 def module_keyword_loc location = @module_keyword_loc return location if location.is_a?(Location) @module_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by module_keyword_loc.
Node Interface
These methods are present on all subclasses of Node. Read the node interface docs for more information.
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 21952 def accept(visitor) visitor.visit_module_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 21959 def child_nodes [constant_path, body] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 21987 def comment_targets [module_keyword_loc, constant_path, *body, end_keyword_loc] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 21977 def compact_child_nodes compact = [] #: Array[Prism::node] compact << constant_path if (body = self.body); compact << body; end compact end
Source
# File lib/prism/node.rb, line 21997 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
Creates a copy of self with the given fields, using self as the template.
Source
# File lib/prism/node.rb, line 21967 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield constant_path if (body = self.body); yield body; end end
See Node.each_child_node.
Repository
Methods related to Relocation.
Public Instance Methods
Source
# File lib/prism/node.rb, line 22099 def save_end_keyword_loc(repository) repository.enter(node_id, :end_keyword_loc) end
Save the end_keyword_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 22057 def save_module_keyword_loc(repository) repository.enter(node_id, :module_keyword_loc) end
Save the module_keyword_loc location using the given saved source so that it can be retrieved later.
Slicing
Public Instance Methods
Source
# File lib/prism/node.rb, line 22131 def end_keyword end_keyword_loc.slice end
Slice the location of end_keyword_loc from the source.
Source
# File lib/prism/node.rb, line 22121 def module_keyword module_keyword_loc.slice end
Slice the location of module_keyword_loc from the source.