Class: Yadriggy::Const
- Defined in:
- lib/yadriggy/ast.rb,
lib/yadriggy/ast_value.rb
Overview
Constant variable such as a class name.
Instance Attribute Summary
Attributes inherited from Name
Attributes inherited from ASTnode
Class Method Summary collapse
Instance Method Summary collapse
-
#accept(evaluator) ⇒ void
A method for Visitor pattern.
- #const_value ⇒ Object
- #const_value_in_class(clazz) ⇒ Object
-
#initialize(sexp) ⇒ Const
constructor
A new instance of Const.
- #value ⇒ Object
- #value_in_class(clazz) ⇒ Object
Methods inherited from Name
Methods inherited from ASTnode
#add_child, #add_children, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string
Constructor Details
#initialize(sexp) ⇒ Const
Returns a new instance of Const.
129 130 131 |
# File 'lib/yadriggy/ast.rb', line 129 def initialize(sexp) super(sexp) end |
Class Method Details
.tag ⇒ Object
127 |
# File 'lib/yadriggy/ast.rb', line 127 def self.tag() :@const end |
Instance Method Details
#accept(evaluator) ⇒ void
This method returns an undefined value.
A method for Visitor pattern.
136 137 138 |
# File 'lib/yadriggy/ast.rb', line 136 def accept(evaluator) evaluator.const(self) end |
#const_value ⇒ Object
148 |
# File 'lib/yadriggy/ast_value.rb', line 148 def const_value() value end |
#const_value_in_class(clazz) ⇒ Object
158 159 160 |
# File 'lib/yadriggy/ast_value.rb', line 158 def const_value_in_class(clazz) value_in_class(clazz) end |
#value ⇒ Object
144 145 146 |
# File 'lib/yadriggy/ast_value.rb', line 144 def value() value_in_class(get_context_class) end |
#value_in_class(clazz) ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/yadriggy/ast_value.rb', line 150 def value_in_class(clazz) if clazz.const_defined?(@name) clazz.const_get(@name) else Undef end end |