Class: Zaid::Runtime::ZaidClass

Inherits:
ZaidObject show all
Defined in:
lib/zaid/runtime/zaid_class.rb

Instance Attribute Summary collapse

Attributes inherited from ZaidObject

#ruby_value, #runtime_class

Instance Method Summary collapse

Methods inherited from ZaidObject

#call

Constructor Details

#initialize(superclass = nil) ⇒ ZaidClass

Returns a new instance of ZaidClass.



10
11
12
13
14
# File 'lib/zaid/runtime/zaid_class.rb', line 10

def initialize(superclass = nil)
  @runtime_methods = {}
  @runtime_superclass = superclass
  @runtime_class = Constants['نوع']
end

Instance Attribute Details

#runtime_methodsObject (readonly)

Returns the value of attribute runtime_methods.



8
9
10
# File 'lib/zaid/runtime/zaid_class.rb', line 8

def runtime_methods
  @runtime_methods
end

Instance Method Details

#def(method_name, &block) ⇒ Object



28
29
30
# File 'lib/zaid/runtime/zaid_class.rb', line 28

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

#lookup(method_name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/zaid/runtime/zaid_class.rb', line 16

def lookup(method_name)
  method = @runtime_methods[method_name]

  unless method
    return @runtime_superclass.lookup(method_name) if @runtime_superclass

    raise "الدالة `#{method_name}` غير موجودة."
  end

  method
end

#newObject



32
33
34
# File 'lib/zaid/runtime/zaid_class.rb', line 32

def new
  ZaidObject.new(self)
end

#new_with_value(value) ⇒ Object



36
37
38
# File 'lib/zaid/runtime/zaid_class.rb', line 36

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