class Prism::ModuleNode
Represents a module declaration involving the module keyword.
module Foo end ^^^^^^^^^^^^^^
Public Class Methods
Source
# File lib/prism/node.rb, line 17621 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 17744 def body @body end
Returns the body attribute.
Source
# File lib/prism/node.rb, line 17736 def constant_path @constant_path end
Returns the constant_path attribute.
Source
# File lib/prism/node.rb, line 17710 def locals @locals end
Returns the locals attribute.
Source
# File lib/prism/node.rb, line 17770 def name @name end
Returns the name attribute.
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 17753 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 17719 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
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 17646 def accept(visitor) visitor.visit_module_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 17651 def child_nodes [constant_path, body] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 17672 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 17664 def compact_child_nodes compact = [] #: Array[Prism::node] compact << constant_path compact << body if body compact end
Source
# File lib/prism/node.rb, line 17680 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 17656 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
Public Instance Methods
Source
# File lib/prism/node.rb, line 17762 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 17728 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 17788 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 17780 def module_keyword module_keyword_loc.slice end
Slice the location of module_keyword_loc from the source.