class Prism::ClassNode
Represents a class declaration involving theclass keyword.
class Foo end^^^^^^^^^^^^^
Attributes
Represents the body of the class.
class Foo foo ^^^
The name of the class.
classFooend# name `:Foo`
Represents the superclass of the class.
class Foo < Bar ^^^
Public Class Methods
Source
# File lib/prism/node.rb, line 3858definitialize(source,node_id,location,flags,locals,class_keyword_loc,constant_path,inheritance_operator_loc,superclass,body,end_keyword_loc,name)@source =source@node_id =node_id@location =location@flags =flags@locals =locals@class_keyword_loc =class_keyword_loc@constant_path =constant_path@inheritance_operator_loc =inheritance_operator_loc@superclass =superclass@body =body@end_keyword_loc =end_keyword_loc@name =nameend
Initialize a newClassNode node.
Source
# File lib/prism/node.rb, line 4014defself.type:class_nodeend
Return a symbol representation of this node type. SeeNode::type.
Public Instance Methods
Source
# File lib/prism/node.rb, line 4020def===(other)other.is_a?(ClassNode)&& (locals.length==other.locals.length)&&locals.zip(other.locals).all? {|left,right|left===right }&& (class_keyword_loc.nil?==other.class_keyword_loc.nil?)&& (constant_path===other.constant_path)&& (inheritance_operator_loc.nil?==other.inheritance_operator_loc.nil?)&& (superclass===other.superclass)&& (body===other.body)&& (end_keyword_loc.nil?==other.end_keyword_loc.nil?)&& (name===other.name)end
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
Source
# File lib/prism/node.rb, line 3874defaccept(visitor)visitor.visit_class_node(self)end
def accept: (Visitor visitor) -> void
Source
# File lib/prism/node.rb, line 3879defchild_nodes [constant_path,superclass,body]end
defchild_nodes: () ->Array
Source
# File lib/prism/node.rb, line 3989defclass_keywordclass_keyword_loc.sliceend
defclass_keyword: () ->String
Source
# File lib/prism/node.rb, line 3917defclass_keyword_loclocation =@class_keyword_locreturnlocationiflocation.is_a?(Location)@class_keyword_loc =Location.new(source,location>>32,location&0xFFFFFFFF)end
Represents the location of theclass keyword.
class Foo end^^^^^
Source
# File lib/prism/node.rb, line 3893defcomment_targets [class_keyword_loc,constant_path,*inheritance_operator_loc,*superclass,*body,end_keyword_loc]#: Array[Prism::node | Location]end
defcomment_targets: () -> Array[Node | Location]
Source
# File lib/prism/node.rb, line 3884defcompact_child_nodescompact = []#: Array[Prism::node]compact<<constant_pathcompact<<superclassifsuperclasscompact<<bodyifbodycompactend
defcompact_child_nodes: () ->Array
Source
# File lib/prism/node.rb, line 3898defcopy(node_id:self.node_id,location:self.location,flags:self.flags,locals:self.locals,class_keyword_loc:self.class_keyword_loc,constant_path:self.constant_path,inheritance_operator_loc:self.inheritance_operator_loc,superclass:self.superclass,body:self.body,end_keyword_loc:self.end_keyword_loc,name:self.name)ClassNode.new(source,node_id,location,flags,locals,class_keyword_loc,constant_path,inheritance_operator_loc,superclass,body,end_keyword_loc,name)end
def copy: (?node_id:Integer, ?location:Location, ?flags:Integer, ?locals:Array, ?class_keyword_loc:Location, ?constant_path:ConstantReadNode |ConstantPathNode |CallNode, ?inheritance_operator_loc:Location?, ?superclass: Prism::node?, ?body:StatementsNode |BeginNode | nil, ?end_keyword_loc:Location, ?name:Symbol) ->ClassNode
Source
# File lib/prism/node.rb, line 3906defdeconstruct_keys(keys) {node_id:node_id,location:location,locals:locals,class_keyword_loc:class_keyword_loc,constant_path:constant_path,inheritance_operator_loc:inheritance_operator_loc,superclass:superclass,body:body,end_keyword_loc:end_keyword_loc,name:name }end
defdeconstruct_keys: (Array keys) -> { node_id:Integer, location:Location, locals:Array,class_keyword_loc:Location,constant_path:ConstantReadNode |ConstantPathNode |CallNode,inheritance_operator_loc:Location?, superclass: Prism::node?, body:StatementsNode |BeginNode | nil,end_keyword_loc:Location, name:Symbol }
Source
# File lib/prism/node.rb, line 3999defend_keywordend_keyword_loc.sliceend
defend_keyword: () ->String
Source
# File lib/prism/node.rb, line 3971defend_keyword_loclocation =@end_keyword_locreturnlocationiflocation.is_a?(Location)@end_keyword_loc =Location.new(source,location>>32,location&0xFFFFFFFF)end
Represents the location of theend keyword.
class Foo end ^^^
Source
# File lib/prism/node.rb, line 3994definheritance_operatorinheritance_operator_loc&.sliceend
definheritance_operator: () ->String?
Source
# File lib/prism/node.rb, line 3936definheritance_operator_loclocation =@inheritance_operator_loccaselocationwhennilnilwhenLocationlocationelse@inheritance_operator_loc =Location.new(source,location>>32,location&0xFFFFFFFF)endend
Represents the location of the< operator.
class Foo < Bar ^
Source
# File lib/prism/node.rb, line 4004definspectInspectVisitor.compose(self)end
def inspect ->String
Source
# File lib/prism/node.rb, line 3925defsave_class_keyword_loc(repository)repository.enter(node_id,:class_keyword_loc)end
Save theclass_keyword_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 3979defsave_end_keyword_loc(repository)repository.enter(node_id,:end_keyword_loc)end
Save theend_keyword_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 3950defsave_inheritance_operator_loc(repository)repository.enter(node_id,:inheritance_operator_loc)unless@inheritance_operator_loc.nil?end
Save theinheritance_operator_loc location using the given saved source so that it can be retrieved later.