exchange-rates-generator 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
=== 0.0.7 2010-03-21
|
2
2
|
|
3
|
-
* Added support for grabbing ISO 4217 currency data from http://www.iso.org/iso/support/currency_codes_list-1.htm. Handy for getting nice descriptive currency
|
3
|
+
* Added support for grabbing ISO 4217 currency data from http://www.iso.org/iso/support/currency_codes_list-1.htm. Handy for getting nice descriptive currency names.
|
4
4
|
|
5
5
|
=== 0.0.1 2010-03-16
|
6
6
|
|
@@ -58,20 +58,36 @@ exchange_rates.#{formatter_classname} = function() {
|
|
58
58
|
return '#{@currency.to_s}';
|
59
59
|
},
|
60
60
|
|
61
|
+
// Retrieves an Array of all the supported currency codes.
|
62
|
+
//
|
63
|
+
// @return [Array] All supported currency codes
|
61
64
|
supported_currencies : function() {
|
62
65
|
return [
|
63
66
|
#{rates.keys.collect {|c| " \"#{c}\"" }.join(",\n") }
|
64
67
|
];
|
65
68
|
},
|
66
69
|
|
70
|
+
// Retrieves an exchange rate.
|
71
|
+
//
|
72
|
+
// @param [String, #toString] The target currency that we want the exchange rate for.
|
73
|
+
// @return [Float] The exchange rate
|
67
74
|
get : function(target_currency) {
|
68
75
|
return this.rates()[normalise_code(target_currency)];
|
69
76
|
},
|
70
77
|
|
78
|
+
// Retrieves a human readible name for a currency code
|
79
|
+
//
|
80
|
+
// @param [String, #toString] The target currency that we want the name for.
|
81
|
+
// @return [String] The human readible version of the currency code.
|
71
82
|
name_for_code : function(code) {
|
72
83
|
return this.names_and_codes()[normalise_code(code)];
|
73
84
|
},
|
74
85
|
|
86
|
+
// Convert +amount+ from base_currency to +currency+.
|
87
|
+
//
|
88
|
+
// @param [Float, #to_f] Amount to convert.
|
89
|
+
// @param [String, #to_s] The currency we want to convert to.
|
90
|
+
// @return [Float] The +amount+ converted to +currency+.
|
75
91
|
convert : function(amount, target_currency) {
|
76
92
|
var rate = this.get(target_currency);
|
77
93
|
if ( !rate ) {
|
@@ -81,6 +97,9 @@ exchange_rates.#{formatter_classname} = function() {
|
|
81
97
|
return rate * parseFloat(amount, 10);
|
82
98
|
},
|
83
99
|
|
100
|
+
// The exchange rates relative to base_currency.
|
101
|
+
//
|
102
|
+
// @return [Hash] The exchange rates relative to base_currency.
|
84
103
|
rates : function() {
|
85
104
|
return {
|
86
105
|
"#{@currency.to_s}" : 1.0,
|
@@ -47,15 +47,14 @@ module ExchangeRates
|
|
47
47
|
def base_currency
|
48
48
|
:#{@currency.to_s}
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
|
+
# Retrieves an Array of all the supported currency codes.
|
52
|
+
#
|
53
|
+
# @return [Array] All supported currency codes
|
51
54
|
def supported_currencies
|
52
55
|
rates.keys
|
53
56
|
end
|
54
57
|
|
55
|
-
def name_for_code(code)
|
56
|
-
names_and_codes[normalise_code(code)]
|
57
|
-
end
|
58
|
-
|
59
58
|
# Wires this currency up to use with the Money Gem. It sets it as the default
|
60
59
|
# currency.
|
61
60
|
#
|
@@ -82,6 +81,14 @@ module ExchangeRates
|
|
82
81
|
rates[normalise_code(target_currency)]
|
83
82
|
end
|
84
83
|
|
84
|
+
# Retrieves a human readible name for a currency code
|
85
|
+
#
|
86
|
+
# @param [String, #toString] The target currency that we want the exchange rate for.
|
87
|
+
# @return [String] The human readible version of the currency code.
|
88
|
+
def name_for_code(code)
|
89
|
+
names_and_codes[normalise_code(code)]
|
90
|
+
end
|
91
|
+
|
85
92
|
# Convert +amount+ from base_currency to +currency+.
|
86
93
|
#
|
87
94
|
# @param [Float, #to_f] Amount to convert.
|