class BigDecimal
Utility functions for BigDecimal
Public Instance Methods
btc()
click to toggle source
Returns a rounded to 8 string
# File lib/fyb/util/bigdecimal.rb, line 4 def btc round(8).to_s('F') end
in_btc(price)
click to toggle source
Returns a BigDecimal
with the money amount converted into bitcoin for price
# File lib/fyb/util/bigdecimal.rb, line 22 def in_btc(price) price = Fyb.ask if price == :ask price = Fyb.bid if price == :bid self / BigDecimal(price) end
in_money(price)
click to toggle source
Returns a BigDecimal
with the bitcoin amount converted into real currency
# File lib/fyb/util/bigdecimal.rb, line 14 def in_money(price) price = Fyb.ask if price == :ask price = Fyb.bid if price == :bid self * BigDecimal(price) end
money()
click to toggle source
Returns a rounded to 2 string
# File lib/fyb/util/bigdecimal.rb, line 9 def money round(2).to_s('F') end