class SyntaxTree::SClass
SClass
represents a block of statements that should be evaluated within the context of the singleton class of an object. It’s frequently used to define singleton methods.
class << self end
Attributes
BodyStmt
-
the expressions to be executed
Node
-
the target of the singleton class to enter
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 9818 def initialize(target:, bodystmt:, location:) @target = target @bodystmt = bodystmt @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 9869 def ===(other) other.is_a?(SClass) && target === other.target && bodystmt === other.bodystmt end
Source
# File lib/syntax_tree/node.rb, line 9825 def accept(visitor) visitor.visit_sclass(self) end
Source
# File lib/syntax_tree/node.rb, line 9829 def child_nodes [target, bodystmt] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 9833 def copy(target: nil, bodystmt: nil, location: nil) node = SClass.new( target: target || self.target, bodystmt: bodystmt || self.bodystmt, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 9847 def deconstruct_keys(_keys) { target: target, bodystmt: bodystmt, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 9856 def format(q) q.text("class << ") q.group do q.format(target) q.indent do q.breakable_force q.format(bodystmt) end q.breakable_force end q.text("end") end