Module: ActiveFacts::API::SimpleDelegation

Included in:
Decimal, Int, Real
Defined in:
lib/activefacts/api/numeric.rb

Overview

Fixes behavior of core functions over multiple platform

Instance Method Summary collapse

Instance Method Details

#==(o) ⇒ Object

:nodoc:



30
31
32
# File 'lib/activefacts/api/numeric.rb', line 30

def ==(o)                             #:nodoc:
  __getobj__.==(o)
end

#eql?(v) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
# File 'lib/activefacts/api/numeric.rb', line 22

def eql?(v)
  # Note: This and #hash do not work the way you'd expect,
  # and differently in each Ruby interpreter. If you store
  # an Int or Real in a hash, you cannot reliably retrieve
  # them with the corresponding Integer or Real.
  __getobj__.eql?(delegate_new(v))
end

#hashObject

:nodoc:



42
43
44
# File 'lib/activefacts/api/numeric.rb', line 42

def hash                              #:nodoc:
  __getobj__.hash
end

#initialize(v) ⇒ Object



18
19
20
# File 'lib/activefacts/api/numeric.rb', line 18

def initialize(v)
  __setobj__(delegate_new(v))
end

#inspectObject



54
55
56
# File 'lib/activefacts/api/numeric.rb', line 54

def inspect
  "#{self.class.basename}:#{__getobj__.inspect}"
end

#is_a?(k) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/activefacts/api/numeric.rb', line 46

def is_a?(k)
  __getobj__.is_a?(k) || super
end

#kind_of?(k) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/activefacts/api/numeric.rb', line 50

def kind_of?(k)
  is_a?(k)
end

#to_json(*a) ⇒ Object

:nodoc:



38
39
40
# File 'lib/activefacts/api/numeric.rb', line 38

def to_json(*a)                       #:nodoc:
  __getobj__.to_s
end

#to_s(*a) ⇒ Object

:nodoc:



34
35
36
# File 'lib/activefacts/api/numeric.rb', line 34

def to_s *a                            #:nodoc:
  __getobj__.to_s *a
end