Class: Fixnum

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

Instance Method Summary collapse

Instance Method Details

#*(other_obj) ⇒ Object



100
101
102
103
# File 'lib/hex_values.rb', line 100

def *(other_obj)
  return other_obj * self if other_obj.instance_of? Hexadecimal
  return old_multiply(other_obj)
end

#**(other_obj) ⇒ Object



110
111
112
113
# File 'lib/hex_values.rb', line 110

def **(other_obj)
  return self ** other_obj.to_float if other_obj.instance_of? Hexadecimal
  return old_pow(other_obj)
end

#+(other_obj) ⇒ Object



90
91
92
93
# File 'lib/hex_values.rb', line 90

def +(other_obj)
  return other_obj + self if other_obj.instance_of? Hexadecimal
  return old_sum(other_obj)
end

#-(other_obj) ⇒ Object



95
96
97
98
# File 'lib/hex_values.rb', line 95

def -(other_obj)
  return self.to_hex - other_obj if other_obj.instance_of? Hexadecimal
  return old_min(other_obj)
end

#/(other_obj) ⇒ Object



105
106
107
108
# File 'lib/hex_values.rb', line 105

def /(other_obj)
  return self.to_hex / other_obj if other_obj.instance_of? Hexadecimal
  return old_divide(other_obj)
end

#old_divideObject



83
# File 'lib/hex_values.rb', line 83

alias :old_divide :/

#old_minObject



81
# File 'lib/hex_values.rb', line 81

alias :old_min :-

#old_multiplyObject



82
# File 'lib/hex_values.rb', line 82

alias :old_multiply :*

#old_powObject



84
# File 'lib/hex_values.rb', line 84

alias :old_pow :**

#old_sumObject



80
# File 'lib/hex_values.rb', line 80

alias :old_sum :+

#to_hex(precision = Hexadecimal::MAX_DECIMALS) ⇒ Object



86
87
88
# File 'lib/hex_values.rb', line 86

def to_hex(precision=Hexadecimal::MAX_DECIMALS)
  self.to_f.to_hex(precision)
end