0.0
No commit activity in last 3 years
No release in over 3 years
Supports conversions and arithmetic.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.0.0
 Project Readme

Bitcoin Money!

The Money gem is a popular gem for Ruby. Ruby needs a gem like Money, for Bitcoin!

But BTC is unique, so this simple object should be unique.

Installation

Add this line to your application's Gemfile:

gem 'bitcoin-money'

And then execute:

$ bundle

Or install it yourself as:

$ gem install bitcoin-money

Usage

Require it!

require 'btc'

Create from whichever unit of BTC.

a = BTC.new(0.012) 
b = BTC.from_mbtc(12)
c = BTC.from_satoshis(120000)
a == b # true
b == c # true
# a == b == c

Get value in any unit of BTC.

b # => #<Btc BTC:0.012 mBTC: 12.0 Satoshis: 120000.0>
b.mbtc # => BigDecimal.new('12.0')
b.satoshis # => BigDecimal.new('120000.0')
b.btc # => BigDecimal.new('0.012')

Perform operations.

a + b # == BTC.new(0.024)
a * a # == BTC.new(0.000144)
a / c # == BTC.new(1)
# also ** and -

Contributing

  1. Fork it ( https://github.com/zenchilabs/bitcoin-money/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request