Class: TurmaliClass

Inherits:
TurmaliObject show all
Defined in:
lib/turmali/runtime/class.rb

Instance Attribute Summary collapse

Attributes inherited from TurmaliObject

#ruby_value, #runtime_class

Instance Method Summary collapse

Methods inherited from TurmaliObject

#call

Constructor Details

#initialize(superclass = Constants["Class"]) ⇒ TurmaliClass

Returns a new instance of TurmaliClass.



8
9
10
11
# File 'lib/turmali/runtime/class.rb', line 8

def initialize(superclass=Constants["Class"])
  @runtime_methods = {}
  @runtime_class = superclass 
end

Instance Attribute Details

#runtime_methodsObject (readonly)

Returns the value of attribute runtime_methods.



6
7
8
# File 'lib/turmali/runtime/class.rb', line 6

def runtime_methods
  @runtime_methods
end

Instance Method Details

#def(name, &block) ⇒ Object



24
25
26
# File 'lib/turmali/runtime/class.rb', line 24

def def(name, &block)
  @runtime_methods[name.to_s] = block
end

#lookup(method_name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/turmali/runtime/class.rb', line 13

def lookup(method_name)
  method = @runtime_methods[method_name]
  unless method
    if @runtime_superclass
     return @runtime_superclass.lookup(method_name)
    else
     raise "Method not found: #{method_name}"
  end end
  method
end

#newObject



28
29
30
# File 'lib/turmali/runtime/class.rb', line 28

def new
  TurmaliObject.new(self)
end

#new_with_value(value) ⇒ Object



32
33
34
# File 'lib/turmali/runtime/class.rb', line 32

def new_with_value(value)
  TurmaliObject.new(self, value)
end