class Prism::SingletonClassNode
Represents a singleton class declaration involving the class keyword.
class << self end ^^^^^^^^^^^^^^^^^
Public Class Methods
Source
# File lib/prism/node.rb, line 27991 def initialize(source, node_id, location, flags, locals, class_keyword_loc, operator_loc, expression, body, end_keyword_loc) @source = source @node_id = node_id @location = location @flags = flags @locals = locals @class_keyword_loc = class_keyword_loc @operator_loc = operator_loc @expression = expression @body = body @end_keyword_loc = end_keyword_loc end
Initialize a new SingletonClassNode node.
Public Instance Methods
Source
# File lib/prism/node.rb, line 28165 def body @body end
Returns the body attribute.
Source
# File lib/prism/node.rb, line 28155 def expression @expression end
Returns the expression attribute.
Source
# File lib/prism/node.rb, line 28101 def locals @locals end
Returns the locals attribute.
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 28112 def class_keyword_loc location = @class_keyword_loc return location if location.is_a?(Location) @class_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by class_keyword_loc.
Source
# File lib/prism/node.rb, line 28176 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 28134 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by operator_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 28018 def accept(visitor) visitor.visit_singleton_class_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 28025 def child_nodes [expression, body] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 28053 def comment_targets [class_keyword_loc, operator_loc, expression, *body, end_keyword_loc] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 28043 def compact_child_nodes compact = [] #: Array[Prism::node] compact << expression if (body = self.body); compact << body; end compact end
Source
# File lib/prism/node.rb, line 28063 def copy(node_id: self.node_id, location: self.location, flags: self.flags, locals: self.locals, class_keyword_loc: self.class_keyword_loc, operator_loc: self.operator_loc, expression: self.expression, body: self.body, end_keyword_loc: self.end_keyword_loc) SingletonClassNode.new(source, node_id, location, flags, locals, class_keyword_loc, operator_loc, expression, body, end_keyword_loc) end
Creates a copy of self with the given fields, using self as the template.
Source
# File lib/prism/node.rb, line 28033 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield expression 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 28123 def save_class_keyword_loc(repository) repository.enter(node_id, :class_keyword_loc) end
Save the class_keyword_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 28187 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 28145 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end
Save the operator_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 28199 def class_keyword class_keyword_loc.slice end
Slice the location of class_keyword_loc from the source.
Source
# File lib/prism/node.rb, line 28219 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 28209 def operator operator_loc.slice end
Slice the location of operator_loc from the source.