Class: Yadriggy::ClassDef

Inherits:
ModuleDef show all
Defined in:
lib/yadriggy/ast.rb

Overview

Class definition.

Instance Attribute Summary collapse

Attributes inherited from ModuleDef

#body, #name, #rescue

Attributes inherited from ASTnode

#parent, #usertype

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ModuleDef

#initialize_body

Methods included from AstHelper

#has_tag?, #to_node, #to_nodes

Methods inherited from ASTnode

#add_child, #add_children, #const_value, #const_value_in_class, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string, #value, #value_in_class

Constructor Details

#initialize(sexp) ⇒ ClassDef

Returns a new instance of ClassDef.



1595
1596
1597
1598
1599
1600
1601
# File 'lib/yadriggy/ast.rb', line 1595

def initialize(sexp)
  @name = to_node(sexp[1])  # Const or ConstPathRef
  add_child(@name)
  @superclass = to_node(sexp[2])
  add_child(@superclass)
  initialize_body(has_tag?(sexp[3], :bodystmt))
end

Instance Attribute Details

#superclassASTnode|nil (readonly)

Returns the super class.

Returns:

  • (ASTnode|nil)

    the super class.



1591
1592
1593
# File 'lib/yadriggy/ast.rb', line 1591

def superclass
  @superclass
end

Class Method Details

.tagObject



1593
# File 'lib/yadriggy/ast.rb', line 1593

def self.tag() :class end

Instance Method Details

#accept(evaluator) ⇒ void

This method returns an undefined value.

A method for Visitor pattern.

Parameters:

  • evaluator (Eval)

    the visitor of Visitor pattern.



1606
1607
1608
# File 'lib/yadriggy/ast.rb', line 1606

def accept(evaluator)
  evaluator.class_def(self)
end