module Calculate
Public Instance Methods
*(value)
click to toggle source
# File lib/arithmetic/arithmetic.rb, line 28 def * (value) (@amount * value_exist(value)) end
+(value)
click to toggle source
# File lib/arithmetic/arithmetic.rb, line 20 def + (value) @amount + conv_euro(value) end
-(value)
click to toggle source
# File lib/arithmetic/arithmetic.rb, line 24 def - (value) @amount - conv_euro(value) end
/(value)
click to toggle source
# File lib/arithmetic/arithmetic.rb, line 32 def / (value) (@amount / value_exist(value)) end
<(value)
click to toggle source
# File lib/arithmetic/arithmetic.rb, line 40 def < (value) (@amount < value_exist(value)) end
==(value)
click to toggle source
# File lib/arithmetic/arithmetic.rb, line 44 def == (value) (@amount == value_exist(value)) end
>(value)
click to toggle source
# File lib/arithmetic/arithmetic.rb, line 36 def > (value) (@amount > value_exist(value)) end
conv_euro(value)
click to toggle source
# File lib/arithmetic/arithmetic.rb, line 9 def conv_euro(value) case value.currency when 'EUR' value * 1 when 'USD' value * 1.1 when 'Bitcoin' value * 0.0047 end end
value_exist(value)
click to toggle source
faltó algo de manejo de errores
# File lib/arithmetic/arithmetic.rb, line 5 def value_exist(value) (value.respond_to?(:to_i) ? value : value.amount) end