There is a simple interface to handle this using Google API.
Convert any currency to any other currency using easy to use goog_currency gem
A simple Ruby interface for currency conversion using Google API.
How to use:
Add gem file in Gemfile
gem 'goog_currency'
Use bundle to get this gem installed on your system.
Now in your app code you can use functions like follows:
To Get pounds from usd simply use usd_to_gbp
amount = 223 pounds = GoogCurrency.usd_to_gbp(amount)
Get yen from ponds using gbp_to_jpy
amount = 223 yen = GoogCurrency.gbp_to_jpy(amount)
Similarly ....
pounds = GoogCurrency.jpy_to_gbp(amount) usd = GoogCurrency.gbp_to_usd(amount)
etc...
You have to pass the amount to those functions.
This will throw an exception in case of any error.
Throws GoogCurrency::Exception in case of any error. And,
Throws GoogCurrency::NoMethodException if conversion method syntax is invalid.
You can find the Source Code here
And Gem here
goog_currency License
MIT License This software is provided as is, use it your own risk.
Copyright (c) Girish Sonawane
No comments:
Post a Comment