Add this line to your application's Gemfile:
gem 'wego-currency'
And then execute:
$ bundle
Or install it yourself as:
$ gem install wego-currency
We are getting the rates from gem wego-money-bank
Converting Currencies:
WegoCurrency::Client.convert_amount(amount, currency_code, new_currency_code)
Converting Currencies with usd
as base currency:
WegoCurrency::Client.convert_amount_usd(amount_usd, new_currency_code)
This method is a wrapper method of the above with usd
as a base to convert into new currency code.
To check for all valid currencies:
WegoCurrency::Client.all_currencies
returns an array of currency code.
example: [:sgd,:usd,:clp,:crc]
To check if currency code is valid
WegoCurrency::Client.is_currency_code_valid?(currency_code)
Accepts uppercase or lower case string / symbol. returns boolean
> WegoCurrency::Client.is_currency_code_valid?("sgd")
=> true
> WegoCurrency::Client.is_currency_code_valid?("abc")
=> false
- Fork it ( https://github.com/[my-github-username]/wego-currency/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request