Home

keita edited this page Sep 12, 2010 · 11 revisions
Clone this wiki locally

Home.ja (日本語)

ruby-xurrency

ruby-xurrency is a wrapper library for API xurrency.

Install

% sudo gem install xurrency

Tool

Convert


% xurrency 10000 jpy cny
697.0
(1 jpy = 0.0697 cny)

Show currency codes


% xurrency -l
ars, aud, bgn, brl, cad, chf, cny, cop, czk, dkk, eek, eur, gbp, hkd, hrk, huf, inr, isk,
jpy, krw, lkr, ltl, lvl, mxn, myr, nok, nzd, php, pln, ron, rub, sek, sgd, skk, thb, try,
twd, usd, vef, zar

Library


require "rubygems"
require "xurrency"

# initialize
xu = Xurrency.new

# convert
xu.value(10000, "jpy", "cny") # 10000 JPY → 697.0 CNY
xu.value(100, "cny", "jpy")   # 100 CNY → 1434.72 JPY

# get rates
xu.values("jpy") # => {"cny" => 0.0697, ... }

Results of Xurrency’s methods are cached, so it’s fast (doesn’t connect the server) when calls sencond time.

If you want to update the result, please call Xurrency#update.


xu.update(:values, "jpy")

If you want not to cache, use Xurrency::Request.


Xurrency::Request.values("jpy")

See API documentation for more details.

License

ruby-xurrency is free to use under the terms of Ruby License.

Links

Author

Keita Yamaguchi <keita.yamaguchi@gmail.com>