Class: Type

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/type.rb

Class Method Summary collapse

Class Method Details

._typeof(v) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/lib/type.rb', line 6

def Type._typeof(v)
  return ValueType.tnull if v == nil
  begin
    _g = v.class.to_s
    case(_g)
    when "TrueClass"
      return ValueType.tbool
    when "FalseClass"
      return ValueType.tbool
    when "String"
      return ValueType.tclass(String)
    when "Integer"
      return ValueType.tint
    when "Fixnum"
      return ValueType.tint
    when "Float"
      return ValueType.tfloat
    when "Proc"
      return ValueType.tfunction
    when "Array"
      return ValueType.tclass(Array)
    when "Hash"
      return ValueType.tobject
    else
      return ValueType.tenum(v.class) if v.respond_to?("ISENUM__")
      return ValueType.tclass(v.class) if v.respond_to?("class")
      return ValueType.tunknown
    end
  end
end