From a71fc07ba575d68b1468d2da564dc455e508c344 Mon Sep 17 00:00:00 2001 From: Geert Weening Date: Tue, 3 Jun 2014 15:18:45 -0700 Subject: [PATCH] [FEATURE] add getter for a Currency's iso_code --- src/js/ripple/currency.js | 4 ++++ test/currency-test.js | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/js/ripple/currency.js b/src/js/ripple/currency.js index 0dc8724e..e5b27fd7 100644 --- a/src/js/ripple/currency.js +++ b/src/js/ripple/currency.js @@ -346,6 +346,10 @@ Currency.prototype.to_human = function(opts) { return this.to_json(opts); }; +Currency.prototype.get_iso = function() { + return this._iso_code; +}; + exports.Currency = Currency; // vim:sw=2:sts=2:ts=8:et diff --git a/test/currency-test.js b/test/currency-test.js index 98d31b76..65fc7879 100644 --- a/test/currency-test.js +++ b/test/currency-test.js @@ -172,4 +172,15 @@ describe('Currency', function() { assert.equal(Math.E, cur.get_interest_at(443845330 - 6291418827.05)); }); }); + describe('get_iso', function() { + it('should get "XRP" iso_code', function() { + assert.strictEqual('XRP', currency.from_json('XRP').get_iso()); + }); + it('should get iso_code', function() { + assert.strictEqual('USD', currency.from_json('USD - US Dollar').get_iso()); + }); + it('should get iso_code', function() { + assert.strictEqual('USD', currency.from_json('USD (0.5%pa)').get_iso()); + }); + }); });