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 22480 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 22621 def body @body end
Returns the body attribute.
Source
# File lib/prism/node.rb, line 22613 def expression @expression end
Returns the expression attribute.
Source
# File lib/prism/node.rb, line 22569 def locals @locals end
Returns the locals attribute.
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 22578 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 22630 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 22596 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
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 22505 def accept(visitor) visitor.visit_singleton_class_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 22510 def child_nodes [expression, body] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 22531 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 22523 def compact_child_nodes compact = [] #: Array[Prism::node] compact << expression compact << body if body compact end
Source
# File lib/prism/node.rb, line 22539 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 22515 def each_child_node return to_enum(:each_child_node) unless block_given? yield expression yield body if body end
See Node.each_child_node.
Repository
Public Instance Methods
Source
# File lib/prism/node.rb, line 22587 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 22639 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 22605 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 22649 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 22665 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 22657 def operator operator_loc.slice end
Slice the location of operator_loc from the source.