Class: AjLisp::AtConstantAtom

Inherits:
NamedAtom show all
Defined in:
lib/ajlisp/at_constant_atom.rb

Instance Attribute Summary collapse

Attributes inherited from NamedAtom

#name

Instance Method Summary collapse

Methods inherited from NamedAtom

#isEqualTo, #to_s

Constructor Details

#initialize(name) ⇒ AtConstantAtom

Returns a new instance of AtConstantAtom.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ajlisp/at_constant_atom.rb', line 7

def initialize(name)
    super(name)
    @constant = name[1,name.length]
    words = @constant.split("::")

    @symbols = []
    
    words.each do |word|
        @symbols.push word.intern
    end
end

Instance Attribute Details

#constantObject (readonly)

Returns the value of attribute constant.



5
6
7
# File 'lib/ajlisp/at_constant_atom.rb', line 5

def constant
  @constant
end

Instance Method Details

#evaluate(context) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/ajlisp/at_constant_atom.rb', line 19

def evaluate(context)
    result = Object
    
    @symbols.each do |symbol|
        result = result.const_get symbol
    end
    
    return result
end