Geld

Installation

Add this line to your application's Gemfile:

gem 'geld'

And then execute:

$ bundle

Or install it yourself as:

$ gem install geld

Usage

Configure your convertions

  Geld::Money.convertion_rates("EUR", { "BRL" => 4, "USD" => 1.5 })

Instanciate a new money object

  Geld::Money.new(10, "BRL")
  => 10.00 BRL

Convert to another currency

  Geld::Money.new(10, "BRL").convert_to("USD")
  => 3.10 USD

Do operations with another currency

  Geld::Money.new(10, "EUR") + Geld::Money.new(10, "BRL")
  => 10.25 EUR

Compare with another currency

  Geld::Money.new(1, "EUR") == Geld::Money.new(4, "BRL")
  => true

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

You can also create new example files in the examples folder ruby examples/usage.rb

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/pedroaugusto/geld.

License

The gem is available as open source under the terms of the MIT License.