Module: Real

Extended by:
Real
Included in:
Real
Defined in:
lib/real.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.const_missing(const_name) ⇒ Object (private)

Access to project metadata, e.g. VERSION.



92
93
94
95
# File 'lib/real.rb', line 92

def self.const_missing(const_name)
  name = const_name.to_s.downcase
  index[name] || super(const_name)
end

.indexObject (private)

Load project metadata file.



100
101
102
103
104
105
# File 'lib/real.rb', line 100

def self.index
  @index ||= (
    require 'yaml'
    YAML.load_file(File.join(File.dirname(__FILE__), 'real.yml'))
  )
end

Instance Method Details

#bind_call(c, m, o, *a, &b) ⇒ Object (private)



84
85
86
87
# File 'lib/real.rb', line 84

def bind_call(c, m, o, *a, &b)
  im = c.instance_method(m) 
  im.bind(o).call(*a, &b)    
end

#class(*a, &b) ⇒ Class

Get object’s real class.

Returns:

  • (Class)


18
19
20
# File 'lib/real.rb', line 18

def class(*a, &b)
  bind_call(Object, :class, *a, &b)
end

#id(*a, &b) ⇒ Integer

Get object’s real id.

Returns:

  • (Integer)


11
12
13
# File 'lib/real.rb', line 11

def id(*a, &b)
  bind_call(Object, :object_id, *a, &b)
end

#instance_methods(*a, &b) ⇒ Array<Symbol>

Get class/module’s real instance methods.

Returns:

  • (Array<Symbol>)


57
58
59
# File 'lib/real.rb', line 57

def instance_methods(*a, &b)
  bind_call(Module, :instanance_methods, *a, &b)
end

#methods(*a, &b) ⇒ Array<Symbol>

Get object’s real methods.

Returns:

  • (Array<Symbol>)


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

def methods(*a, &b)
  bind_call(Object, :methods, *a, &b)
end

#private_instance_methods(*a, &b) ⇒ Array<Symbol>

Get class/module’s real private instance methods.

Returns:

  • (Array<Symbol>)


78
79
80
# File 'lib/real.rb', line 78

def private_instance_methods(*a, &b)
  bind_call(Module, :private_instance_methods, :class, *a, &b)
end

#private_methods(*a, &b) ⇒ Array<Symbol>

Get object’s real private methods.

Returns:

  • (Array<Symbol>)


46
47
48
# File 'lib/real.rb', line 46

def private_methods(*a, &b)
  bind_call(Object, :private_methods, *a, &b)
end

#protected_instance_methods(*a, &b) ⇒ Array<Symbol>

Get class/module’s real protected instance methods.

Returns:

  • (Array<Symbol>)


71
72
73
# File 'lib/real.rb', line 71

def protected_instance_methods(*a, &b)
  bind_call(Module, :protected_instance_methods, *a, &b)
end

#protected_methods(*a, &b) ⇒ Array<Symbol>

Get object’s real protected methods.

Returns:

  • (Array<Symbol>)


39
40
41
# File 'lib/real.rb', line 39

def protected_methods(*a, &b)
  bind_call(Object, :protected_methods, *a, &b)
end

#public_instance_methods(*a, &b) ⇒ Array<Symbol>

Get class/module’s real public instance methods.

Returns:

  • (Array<Symbol>)


64
65
66
# File 'lib/real.rb', line 64

def public_instance_methods(*a, &b)
  bind_call(Module, :public_instance_methods, *a, &b)
end

#public_methods(*a, &b) ⇒ Array<Symbol>

Get object’s real public methods.

Returns:

  • (Array<Symbol>)


32
33
34
# File 'lib/real.rb', line 32

def public_methods(*a, &b)
  bind_call(Object, :public_methods, *a, &b)
end