Class: BigDecimal
- Inherits:
-
Object
- Object
- BigDecimal
- Defined in:
- lib/fyb/util/bigdecimal.rb
Overview
Utility functions for BigDecimal
Instance Method Summary collapse
-
#btc ⇒ Object
Returns a rounded to 8 string.
-
#in_btc(price) ⇒ Object
Returns a BigDecimal with the money amount converted into bitcoin for
price
. -
#in_money(price) ⇒ Object
Returns a BigDecimal with the bitcoin amount converted into real currency.
-
#money ⇒ Object
Returns a rounded to 2 string.
Instance Method Details
#btc ⇒ Object
Returns a rounded to 8 string
4 5 6 |
# File 'lib/fyb/util/bigdecimal.rb', line 4 def btc round(8).to_s('F') end |
#in_btc(price) ⇒ Object
Returns a BigDecimal with the money amount converted into bitcoin for price
22 23 24 25 26 27 |
# 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) ⇒ Object
Returns a BigDecimal with the bitcoin amount converted into real currency
14 15 16 17 18 19 |
# 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 ⇒ Object
Returns a rounded to 2 string
9 10 11 |
# File 'lib/fyb/util/bigdecimal.rb', line 9 def money round(2).to_s('F') end |