class Prism::ModuleNode
Represents a module declaration involving the module keyword.
module Foo end ^^^^^^^^^^^^^^
Public Class Methods
Source
# File lib/prism/node.rb, line 17622 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 17745 def body @body end
Returns the body attribute.
Source
# File lib/prism/node.rb, line 17737 def constant_path @constant_path end
Returns the constant_path attribute.
Source
# File lib/prism/node.rb, line 17711 def locals @locals end
Returns the locals attribute.
Source
# File lib/prism/node.rb, line 17771 def name @name end
Returns the name attribute.
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 17754 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 17720 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 17647 def accept(visitor) visitor.visit_module_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 17652 def child_nodes [constant_path, body] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 17673 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 17665 def compact_child_nodes compact = [] #: Array[Prism::node] compact << constant_path compact << body if body compact end
Source
# File lib/prism/node.rb, line 17681 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 17657 def each_child_node return to_enum(:each_child_node) unless block_given? yield constant_path yield body if body end
See Node.each_child_node.
Repository
Methods related to Relocation.
Public Instance Methods
Source
# File lib/prism/node.rb, line 17763 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 17729 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 17789 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 17781 def module_keyword module_keyword_loc.slice end
Slice the location of module_keyword_loc from the source.