class Prism::SingletonClassNode
Represents a singleton class declaration involving the class keyword.
class << self end ^^^^^^^^^^^^^^^^^
Public Class Methods
(Source source, Integer node_id, Location location, Integer flags, Array[Symbol] locals, Location class_keyword_loc, Location operator_loc, Prism::node expression, (StatementsNode | BeginNode)? body, Location end_keyword_loc) → void
Source
# File lib/prism/node.rb, line 29608 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 29798 def body @body end
Returns the body attribute.
() → Prism::node
Source
# File lib/prism/node.rb, line 29788 def expression @expression end
Returns the expression attribute.
Source
# File lib/prism/node.rb, line 29734 def locals @locals end
Returns the locals attribute.
Locations
Public Instance Methods
() → Location
Source
# File lib/prism/node.rb, line 29745 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.
() → Location
Source
# File lib/prism/node.rb, line 29809 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.
() → Location
Source
# File lib/prism/node.rb, line 29767 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
(_Visitor visitor) → untyped
Source
# File lib/prism/node.rb, line 29635 def accept(visitor) visitor.visit_singleton_class_node(self) end
See Node.accept.
() → Array[node?]
Source
# File lib/prism/node.rb, line 29642 def child_nodes [expression, body] end
See Node.child_nodes.
() → Array[node | Location]
Source
# File lib/prism/node.rb, line 29670 def comment_targets [class_keyword_loc, operator_loc, expression, *body, end_keyword_loc] #: Array[Prism::node | Location] end
See Node.comment_targets.
() → Array[node]
Source
# File lib/prism/node.rb, line 29660 def compact_child_nodes compact = [] #: Array[Prism::node] compact << expression if (body = self.body); compact << body; end compact end
(?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array[Symbol], ?class_keyword_loc: Location, ?operator_loc: Location, ?expression: Prism::node, ?body: (StatementsNode | BeginNode)?, ?end_keyword_loc: Location) → SingletonClassNode
Source
# File lib/prism/node.rb, line 29680 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.
() → Enumerator[node, void]
() { (node) → void } → void
Source
# File lib/prism/node.rb, line 29650 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
(_Repository repository) → Relocation::Entry
Source
# File lib/prism/node.rb, line 29756 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.
(_Repository repository) → Relocation::Entry
Source
# File lib/prism/node.rb, line 29820 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.
(_Repository repository) → Relocation::Entry
Source
# File lib/prism/node.rb, line 29778 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 29832 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 29852 def end_keyword end_keyword_loc.slice end
Slice the location of end_keyword_loc from the source.
() → String
Source
# File lib/prism/node.rb, line 29842 def operator operator_loc.slice end
Slice the location of operator_loc from the source.