Class: Reflect

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

Class Method Summary collapse

Class Method Details

.compare(a, b) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/lib/reflect.rb', line 29

def Reflect.compare(a,b)
  if a == b 
    return 0
  elsif a > b 
    return 1
  else 
    return -1
  end
end

.field(o, field) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/lib/reflect.rb', line 6

def Reflect.field(o,field)
  begin
    result = o[field]
    result = o[field.to_sym] if result == nil
    return result
  rescue => e
    e = hx_rescued(e)
    return field
  end
end

.fields(o) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/lib/reflect.rb', line 17

def Reflect.fields(o)
  if o.respond_to?("attributes") 
    return o.attributes
  else 
    return o.keys
  end
end

.is_function(f) ⇒ Object



25
26
27
# File 'lib/lib/reflect.rb', line 25

def Reflect.is_function(f)
  f.respond_to?("call")
end