Sha256: b42e2b972a33ad501a7d35d5d4e2b4ef4d1a676d2200ab355516ae903e05a9cc
Contents?: true
Size: 703 Bytes
Versions: 1
Compression:
Stored size: 703 Bytes
Contents
class Bitcoin def initialize(value, unit = nil) @value = value @unit = unit @satoshi = convert_to_satoshi if @unit end def convert_to_satoshi case @unit when :btc @value * 100000000 when :bit @value * 100 when :sat @value else @value end end def to_bit @satoshi / 100.0 end def to_btc @satoshi / 100000000.0 end alias :to_coin :to_btc def to_satoshi @satoshi end def to_smallest to_satoshi end def smallest_to_coin @unit ||= :sat @satoshi = @value to_coin end def coin_to_smallest @unit ||= :btc @satoshi = convert_to_satoshi to_smallest end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
currency_units-0.1.6 | lib/currency_units/currencies/bitcoin.rb |