money 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,10 @@
1
+ == Money 3.0.4
2
+ * Updated #exchange to avoid floating point rounding errors
3
+ * Use :subunit_to_unit in #to_s, #to_f and #format
4
+ * Added :separator and :delimiter to Currency
5
+ * Deprecated Money#SEPARATORS and Money#DELIMITERS
6
+ * Updated the attributes of the Chilean Peso
7
+
1
8
  == Money 3.0.3
2
9
  * Added #currency_as_string and #currency_as_string= for easier integration
3
10
  with ActiveRecord/Rails
@@ -73,7 +73,9 @@ containing all the currency attributes.
73
73
  :name => "United States Dollar",
74
74
  :symbol => "$",
75
75
  :subunit => "Cent"
76
- :subunit_to_unit => "100"
76
+ :subunit_to_unit => "100",
77
+ :separator => ".",
78
+ :delimiter =? ","
77
79
  }
78
80
 
79
81
  The pre-defined set of attributes includes:
@@ -84,6 +86,8 @@ The pre-defined set of attributes includes:
84
86
  * symbol: the currency symbol (UTF-8 encoded)
85
87
  * subunit: the name of the fractional monetary unit
86
88
  * subunit_to_unit: the proportion between the unit and the subunit
89
+ * separator: character between the whole and fraction amounts
90
+ * delimiter: character between each thousands place
87
91
 
88
92
  All attributes are optional. Some attributes, such as <tt>:symbol</tt>, are used by the Money class
89
93
  to print out a representation of the object. Other attributes, such as <tt>:name</tt> or <tt>:priority</tt>,
@@ -172,7 +176,10 @@ field.
172
176
 
173
177
  class ProductUnit < ActiveRecord::Base
174
178
  belongs_to :product
175
- composed_of :price, :class_name => "Money", :mapping => [%w(cents cents), %w(currency currency_as_string)]
179
+ composed_of :price,
180
+ :class_name => "Money",
181
+ :mapping => [%w(cents cents), %w(currency currency_as_string)],
182
+ :constructor => Proc.new { |cents, currency| Money.new(cents || 0, currency || Money.default_currency) }
176
183
 
177
184
  private
178
185
  validate :cents_not_zero
@@ -188,6 +195,9 @@ field.
188
195
  For Money 2.2.x and previous versions, simply use the following
189
196
  <tt>composed_of</tt> definition:
190
197
 
191
- composed_of :price, :class_name => "Money", :mapping => [%w(cents cents), %w(currency currency)]
198
+ composed_of :price,
199
+ :class_name => "Money",
200
+ :mapping => [%w(cents cents), %w(currency currency)],
201
+ :constructor => Proc.new { |cents, currency| Money.new(cents || 0, currency || Money.default_currency) }
192
202
 
193
203
  For further details read the full discussion at http://github.com/FooBarWidget/money/issues/4#comment_224880
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.3
1
+ 3.0.4
@@ -15,7 +15,7 @@ class Money
15
15
  # * symbol: the currency symbol (UTF-8 encoded)
16
16
  # * subunit: the name of the fractional monetary unit
17
17
  # * subunit_to_unit: the proportion between the unit and the subunit
18
- ATTRIBUTES = [ :priority, :iso_code, :name, :symbol, :subunit, :subunit_to_unit ]
18
+ ATTRIBUTES = [ :priority, :iso_code, :name, :symbol, :subunit, :subunit_to_unit, :separator, :delimiter ]
19
19
 
20
20
  TABLE = {
21
21
  # monetary unit
@@ -26,172 +26,172 @@ class Money
26
26
  # http://www.answers.com/topic/fractional-monetary-unit-subunit
27
27
  #
28
28
  # See http://en.wikipedia.org/wiki/List_of_circulating_currencies
29
- :aed => { :priority => 100, :iso_code => "AED", :name => "United Arab Emirates Dirham", :symbol => "د.إ", :subunit => "Fils", :subunit_to_unit => "100" },
30
- :afn => { :priority => 100, :iso_code => "AFN", :name => "Afghan Afghani", :symbol => "؋", :subunit => "Pul", :subunit_to_unit => "100" },
31
- :all => { :priority => 100, :iso_code => "ALL", :name => "Albanian Lek", :symbol => "L", :subunit => "Qintar", :subunit_to_unit => "100" },
32
- :amd => { :priority => 100, :iso_code => "AMD", :name => "Armenian Dram", :symbol => "դր.", :subunit => "Luma", :subunit_to_unit => "100" },
33
- :ang => { :priority => 100, :iso_code => "ANG", :name => "Netherlands Antillean Gulden", :symbol => "ƒ", :subunit => "Cent", :subunit_to_unit => "100" },
34
- :aoa => { :priority => 100, :iso_code => "AOA", :name => "Angolan Kwanza", :symbol => "Kz", :subunit => "Cêntimo", :subunit_to_unit => "100" },
35
- :ars => { :priority => 100, :iso_code => "ARS", :name => "Argentine Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => "100" },
36
- :aud => { :priority => 4, :iso_code => "AUD", :name => "Australian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
37
- :awg => { :priority => 100, :iso_code => "AWG", :name => "Aruban Florin", :symbol => "ƒ", :subunit => "Cent", :subunit_to_unit => "100" },
38
- :azn => { :priority => 100, :iso_code => "AZN", :name => "Azerbaijani Manat", :symbol => nil, :subunit => "Qəpik", :subunit_to_unit => "100" },
39
- :bam => { :priority => 100, :iso_code => "BAM", :name => "Bosnia and Herzegovina Convertible Mark", :symbol => "KM or КМ", :subunit => "Fening", :subunit_to_unit => "100" },
40
- :bbd => { :priority => 100, :iso_code => "BBD", :name => "Barbadian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
41
- :bdt => { :priority => 100, :iso_code => "BDT", :name => "Bangladeshi Taka", :symbol => "৳", :subunit => "Paisa", :subunit_to_unit => "100" },
42
- :bgn => { :priority => 100, :iso_code => "BGN", :name => "Bulgarian Lev", :symbol => "лв", :subunit => "Stotinka", :subunit_to_unit => "100" },
43
- :bhd => { :priority => 100, :iso_code => "BHD", :name => "Bahraini Dinar", :symbol => "ب.د", :subunit => "Fils", :subunit_to_unit => "1,000" },
44
- :bif => { :priority => 100, :iso_code => "BIF", :name => "Burundian Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => "100" },
45
- :bmd => { :priority => 100, :iso_code => "BMD", :name => "Bermudian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
46
- :bnd => { :priority => 100, :iso_code => "BND", :name => "Brunei Dollar", :symbol => "$", :subunit => "Sen", :subunit_to_unit => "100" },
47
- :bob => { :priority => 100, :iso_code => "BOB", :name => "Bolivian Boliviano", :symbol => "Bs.", :subunit => "Centavo", :subunit_to_unit => "100" },
48
- :brl => { :priority => 100, :iso_code => "BRL", :name => "Brazilian Real", :symbol => "R$ ", :subunit => "Centavo", :subunit_to_unit => "100" },
49
- :bsd => { :priority => 100, :iso_code => "BSD", :name => "Bahamian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
50
- :btn => { :priority => 100, :iso_code => "BTN", :name => "Bhutanese Ngultrum", :symbol => nil, :subunit => "Chertrum", :subunit_to_unit => "100" },
51
- :bwp => { :priority => 100, :iso_code => "BWP", :name => "Botswana Pula", :symbol => "P", :subunit => "Thebe", :subunit_to_unit => "100" },
52
- :byr => { :priority => 100, :iso_code => "BYR", :name => "Belarusian Ruble", :symbol => "Br", :subunit => "Kapyeyka", :subunit_to_unit => "100" },
53
- :bzd => { :priority => 100, :iso_code => "BZD", :name => "Belize Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
54
- :cad => { :priority => 5, :iso_code => "CAD", :name => "Canadian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
55
- :cdf => { :priority => 100, :iso_code => "CDF", :name => "Congolese Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => "100" },
56
- :chf => { :priority => 100, :iso_code => "CHF", :name => "Swiss Franc", :symbol => "Fr", :subunit => "Rappen", :subunit_to_unit => "100" },
57
- :chf => { :priority => 100, :iso_code => "CHF", :name => "Swiss Franc", :symbol => "Fr", :subunit => "Rappen", :subunit_to_unit => "100" },
58
- :clp => { :priority => 100, :iso_code => "CLP", :name => "Chilean Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => "100" },
59
- :cny => { :priority => 100, :iso_code => "CNY", :name => "Chinese Renminbi Yuan", :symbol => "¥", :subunit => "Jiao", :subunit_to_unit => "10" },
60
- :cop => { :priority => 100, :iso_code => "COP", :name => "Colombian Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => "100" },
61
- :crc => { :priority => 100, :iso_code => "CRC", :name => "Costa Rican Colón", :symbol => "₡", :subunit => "Céntimo", :subunit_to_unit => "100" },
62
- :cuc => { :priority => 100, :iso_code => "CUC", :name => "Cuban Convertible Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => "100" },
63
- :cup => { :priority => 100, :iso_code => "CUP", :name => "Cuban Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => "100" },
64
- :cve => { :priority => 100, :iso_code => "CVE", :name => "Cape Verdean Escudo", :symbol => "$ or Esc", :subunit => "Centavo", :subunit_to_unit => "100" },
65
- :czk => { :priority => 100, :iso_code => "CZK", :name => "Czech Koruna", :symbol => "Kč", :subunit => "Haléř", :subunit_to_unit => "100" },
66
- :djf => { :priority => 100, :iso_code => "DJF", :name => "Djiboutian Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => "100" },
67
- :dkk => { :priority => 100, :iso_code => "DKK", :name => "Danish Krone", :symbol => "kr", :subunit => "Øre", :subunit_to_unit => "100" },
68
- :dop => { :priority => 100, :iso_code => "DOP", :name => "Dominican Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => "100" },
69
- :dzd => { :priority => 100, :iso_code => "DZD", :name => "Algerian Dinar", :symbol => "د.ج", :subunit => "Centime", :subunit_to_unit => "100" },
70
- :eek => { :priority => 100, :iso_code => "EEK", :name => "Estonian Kroon", :symbol => "KR", :subunit => "Sent", :subunit_to_unit => "100" },
71
- :egp => { :priority => 100, :iso_code => "EGP", :name => "Egyptian Pound", :symbol => "£ or ج.م", :subunit => "Piastre", :subunit_to_unit => "100" },
72
- :ern => { :priority => 100, :iso_code => "ERN", :name => "Eritrean Nakfa", :symbol => "Nfk", :subunit => "Cent", :subunit_to_unit => "100" },
73
- :etb => { :priority => 100, :iso_code => "ETB", :name => "Ethiopian Birr", :symbol => nil, :subunit => "Santim", :subunit_to_unit => "100" },
74
- :eur => { :priority => 2, :iso_code => "EUR", :name => "Euro", :symbol => "€", :subunit => "Cent", :subunit_to_unit => "100" },
75
- :fjd => { :priority => 100, :iso_code => "FJD", :name => "Fijian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
76
- :fkp => { :priority => 100, :iso_code => "FKP", :name => "Falkland Pound", :symbol => "£", :subunit => "Penny", :subunit_to_unit => "100" },
77
- :gbp => { :priority => 3, :iso_code => "GBP", :name => "British Pound", :symbol => "£", :subunit => "Penny", :subunit_to_unit => "100" },
78
- :gel => { :priority => 100, :iso_code => "GEL", :name => "Georgian Lari", :symbol => "ლ", :subunit => "Tetri", :subunit_to_unit => "100" },
79
- :ghc => { :priority => 100, :iso_code => "GHC", :name => "Ghanaian Cedi", :symbol => "₵", :subunit => "Pesewa", :subunit_to_unit => "100" },
80
- :gip => { :priority => 100, :iso_code => "GIP", :name => "Gibraltar Pound", :symbol => "£", :subunit => "Penny", :subunit_to_unit => "100" },
81
- :gmd => { :priority => 100, :iso_code => "GMD", :name => "Gambian Dalasi", :symbol => "D", :subunit => "Butut", :subunit_to_unit => "100" },
82
- :gnf => { :priority => 100, :iso_code => "GNF", :name => "Guinean Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => "100" },
83
- :gtq => { :priority => 100, :iso_code => "GTQ", :name => "Guatemalan Quetzal", :symbol => "Q", :subunit => "Centavo", :subunit_to_unit => "100" },
84
- :gyd => { :priority => 100, :iso_code => "GYD", :name => "Guyanese Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
85
- :hkd => { :priority => 100, :iso_code => "HKD", :name => "Hong Kong Dollar", :symbol => "$", :subunit => "Ho", :subunit_to_unit => "10" },
86
- :hnl => { :priority => 100, :iso_code => "HNL", :name => "Honduran Lempira", :symbol => "L", :subunit => "Centavo", :subunit_to_unit => "100" },
87
- :hrk => { :priority => 100, :iso_code => "HRK", :name => "Croatian Kuna", :symbol => "kn", :subunit => "Lipa", :subunit_to_unit => "100" },
88
- :htg => { :priority => 100, :iso_code => "HTG", :name => "Haitian Gourde", :symbol => "G", :subunit => "Centime", :subunit_to_unit => "100" },
89
- :huf => { :priority => 100, :iso_code => "HUF", :name => "Hungarian Forint", :symbol => "Ft", :subunit => "Fillér", :subunit_to_unit => "100" },
90
- :idr => { :priority => 100, :iso_code => "IDR", :name => "Indonesian Rupiah", :symbol => "Rp", :subunit => "Sen", :subunit_to_unit => "100" },
91
- :ils => { :priority => 100, :iso_code => "ILS", :name => "Israeli New Sheqel", :symbol => "₪", :subunit => "Agora", :subunit_to_unit => "100" },
92
- :inr => { :priority => 100, :iso_code => "INR", :name => "Indian Rupee", :symbol => "₨", :subunit => "Paisa", :subunit_to_unit => "100" },
93
- :iqd => { :priority => 100, :iso_code => "IQD", :name => "Iraqi Dinar", :symbol => "ع.د", :subunit => "Fils", :subunit_to_unit => "1,000" },
94
- :irr => { :priority => 100, :iso_code => "IRR", :name => "Iranian Rial", :symbol => "﷼", :subunit => "Dinar", :subunit_to_unit => "100" },
95
- :isk => { :priority => 100, :iso_code => "ISK", :name => "Icelandic Króna", :symbol => "kr", :subunit => "Eyrir", :subunit_to_unit => "100" },
96
- :jmd => { :priority => 100, :iso_code => "JMD", :name => "Jamaican Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
97
- :jod => { :priority => 100, :iso_code => "JOD", :name => "Jordanian Dinar", :symbol => "د.ا", :subunit => "Piastre", :subunit_to_unit => "100" },
98
- :jpy => { :priority => 6, :iso_code => "JPY", :name => "Japanese Yen", :symbol => "¥", :subunit => "Sen", :subunit_to_unit => "100" },
99
- :kes => { :priority => 100, :iso_code => "KES", :name => "Kenyan Shilling", :symbol => "Sh", :subunit => "Cent", :subunit_to_unit => "100" },
100
- :kgs => { :priority => 100, :iso_code => "KGS", :name => "Kyrgyzstani Som", :symbol => nil, :subunit => "Tyiyn", :subunit_to_unit => "100" },
101
- :khr => { :priority => 100, :iso_code => "KHR", :name => "Cambodian Riel", :symbol => "៛", :subunit => "Sen", :subunit_to_unit => "100" },
102
- :kmf => { :priority => 100, :iso_code => "KMF", :name => "Comorian Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => "100" },
103
- :kpw => { :priority => 100, :iso_code => "KPW", :name => "North Korean Won", :symbol => "₩", :subunit => "Chŏn", :subunit_to_unit => "100" },
104
- :krw => { :priority => 100, :iso_code => "KRW", :name => "South Korean Won", :symbol => "₩", :subunit => "Jeon", :subunit_to_unit => "100" },
105
- :kwd => { :priority => 100, :iso_code => "KWD", :name => "Kuwaiti Dinar", :symbol => "د.ك", :subunit => "Fils", :subunit_to_unit => "1,000" },
106
- :kyd => { :priority => 100, :iso_code => "KYD", :name => "Cayman Islands Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
107
- :kzt => { :priority => 100, :iso_code => "KZT", :name => "Kazakhstani Tenge", :symbol => "〒", :subunit => "Tiyn", :subunit_to_unit => "100" },
108
- :lak => { :priority => 100, :iso_code => "LAK", :name => "Lao Kip", :symbol => "₭", :subunit => "Att", :subunit_to_unit => "100" },
109
- :lbp => { :priority => 100, :iso_code => "LBP", :name => "Lebanese Lira", :symbol => "ل.ل", :subunit => "Piastre", :subunit_to_unit => "100" },
110
- :lkr => { :priority => 100, :iso_code => "LKR", :name => "Sri Lankan Rupee", :symbol => "₨", :subunit => "Cent", :subunit_to_unit => "100" },
111
- :lrd => { :priority => 100, :iso_code => "LRD", :name => "Liberian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
112
- :lsl => { :priority => 100, :iso_code => "LSL", :name => "Lesotho Loti", :symbol => "L", :subunit => "Sente", :subunit_to_unit => "100" },
113
- :ltl => { :priority => 100, :iso_code => "LTL", :name => "Lithuanian Litas", :symbol => "Lt", :subunit => "Centas", :subunit_to_unit => "100" },
114
- :lvl => { :priority => 100, :iso_code => "LVL", :name => "Latvian Lats", :symbol => "Ls", :subunit => "Santīms", :subunit_to_unit => "100" },
115
- :lyd => { :priority => 100, :iso_code => "LYD", :name => "Libyan Dinar", :symbol => "ل.د", :subunit => "Dirham", :subunit_to_unit => "1,000" },
116
- :mad => { :priority => 100, :iso_code => "MAD", :name => "Moroccan Dirham", :symbol => "د.م.", :subunit => "Centime", :subunit_to_unit => "100" },
117
- :mdl => { :priority => 100, :iso_code => "MDL", :name => "Moldovan Leu", :symbol => "L", :subunit => "Ban", :subunit_to_unit => "100" },
118
- :mga => { :priority => 100, :iso_code => "MGA", :name => "Malagasy Ariary", :symbol => nil, :subunit => "Iraimbilanja", :subunit_to_unit => "5" },
119
- :mkd => { :priority => 100, :iso_code => "MKD", :name => "Macedonian Denar", :symbol => "ден", :subunit => "Deni", :subunit_to_unit => "100" },
120
- :mmk => { :priority => 100, :iso_code => "MMK", :name => "Myanmar Kyat", :symbol => "K", :subunit => "Pya", :subunit_to_unit => "100" },
121
- :mnt => { :priority => 100, :iso_code => "MNT", :name => "Mongolian Tögrög", :symbol => "₮", :subunit => "Möngö", :subunit_to_unit => "100" },
122
- :mop => { :priority => 100, :iso_code => "MOP", :name => "Macanese Pataca", :symbol => "P", :subunit => "Avo", :subunit_to_unit => "100" },
123
- :mro => { :priority => 100, :iso_code => "MRO", :name => "Mauritanian Ouguiya", :symbol => "UM", :subunit => "Khoums", :subunit_to_unit => "5" },
124
- :mur => { :priority => 100, :iso_code => "MUR", :name => "Mauritian Rupee", :symbol => "₨", :subunit => "Cent", :subunit_to_unit => "100" },
125
- :mvr => { :priority => 100, :iso_code => "MVR", :name => "Maldivian Rufiyaa", :symbol => "ރ.", :subunit => "Laari", :subunit_to_unit => "100" },
126
- :mwk => { :priority => 100, :iso_code => "MWK", :name => "Malawian Kwacha", :symbol => "MK", :subunit => "Tambala", :subunit_to_unit => "100" },
127
- :mxn => { :priority => 100, :iso_code => "MXN", :name => "Mexican Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => "100" },
128
- :myr => { :priority => 100, :iso_code => "MYR", :name => "Malaysian Ringgit", :symbol => "RM", :subunit => "Sen", :subunit_to_unit => "100" },
129
- :mzn => { :priority => 100, :iso_code => "MZN", :name => "Mozambican Metical", :symbol => "MTn", :subunit => "Centavo", :subunit_to_unit => "100" },
130
- :nad => { :priority => 100, :iso_code => "NAD", :name => "Namibian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
131
- :ngn => { :priority => 100, :iso_code => "NGN", :name => "Nigerian Naira", :symbol => "₦", :subunit => "Kobo", :subunit_to_unit => "100" },
132
- :nio => { :priority => 100, :iso_code => "NIO", :name => "Nicaraguan Córdoba", :symbol => "C$", :subunit => "Centavo", :subunit_to_unit => "100" },
133
- :nok => { :priority => 100, :iso_code => "NOK", :name => "Norwegian Krone", :symbol => "kr", :subunit => "Øre", :subunit_to_unit => "100" },
134
- :npr => { :priority => 100, :iso_code => "NPR", :name => "Nepalese Rupee", :symbol => "₨", :subunit => "Paisa", :subunit_to_unit => "100" },
135
- :nzd => { :priority => 100, :iso_code => "NZD", :name => "New Zealand Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
136
- :omr => { :priority => 100, :iso_code => "OMR", :name => "Omani Rial", :symbol => "ر.ع.", :subunit => "Baisa", :subunit_to_unit => "1,000" },
137
- :pab => { :priority => 100, :iso_code => "PAB", :name => "Panamanian Balboa", :symbol => "B/.", :subunit => "Centésimo", :subunit_to_unit => "100" },
138
- :pen => { :priority => 100, :iso_code => "PEN", :name => "Peruvian Nuevo Sol", :symbol => "S/.", :subunit => "Céntimo", :subunit_to_unit => "100" },
139
- :pgk => { :priority => 100, :iso_code => "PGK", :name => "Papua New Guinean Kina", :symbol => "K", :subunit => "Toea", :subunit_to_unit => "100" },
140
- :php => { :priority => 100, :iso_code => "PHP", :name => "Philippine Peso", :symbol => "₱", :subunit => "Centavo", :subunit_to_unit => "100" },
141
- :pkr => { :priority => 100, :iso_code => "PKR", :name => "Pakistani Rupee", :symbol => "₨", :subunit => "Paisa", :subunit_to_unit => "100" },
142
- :pln => { :priority => 100, :iso_code => "PLN", :name => "Polish Złoty", :symbol => "zł", :subunit => "Grosz", :subunit_to_unit => "100" },
143
- :pyg => { :priority => 100, :iso_code => "PYG", :name => "Paraguayan Guaraní", :symbol => "₲", :subunit => "Céntimo", :subunit_to_unit => "100" },
144
- :qar => { :priority => 100, :iso_code => "QAR", :name => "Qatari Riyal", :symbol => "ر.ق", :subunit => "Dirham", :subunit_to_unit => "100" },
145
- :ron => { :priority => 100, :iso_code => "RON", :name => "Romanian Leu", :symbol => "L", :subunit => "Ban", :subunit_to_unit => "100" },
146
- :rsd => { :priority => 100, :iso_code => "RSD", :name => "Serbian Dinar", :symbol => "din. or дин.", :subunit => "Para", :subunit_to_unit => "100" },
147
- :rub => { :priority => 100, :iso_code => "RUB", :name => "Russian Ruble", :symbol => "р.", :subunit => "Kopek", :subunit_to_unit => "100" },
148
- :rub => { :priority => 100, :iso_code => "RUB", :name => "Russian Ruble", :symbol => "руб.", :subunit => "Kopek", :subunit_to_unit => "100" },
149
- :rwf => { :priority => 100, :iso_code => "RWF", :name => "Rwandan Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => "100" },
150
- :sar => { :priority => 100, :iso_code => "SAR", :name => "Saudi Riyal", :symbol => "ر.س", :subunit => "Hallallah", :subunit_to_unit => "100" },
151
- :sbd => { :priority => 100, :iso_code => "SBD", :name => "Solomon Islands Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
152
- :scr => { :priority => 100, :iso_code => "SCR", :name => "Seychellois Rupee", :symbol => "₨", :subunit => "Cent", :subunit_to_unit => "100" },
153
- :sdg => { :priority => 100, :iso_code => "SDG", :name => "Sudanese Pound", :symbol => "£", :subunit => "Piastre", :subunit_to_unit => "100" },
154
- :sek => { :priority => 100, :iso_code => "SEK", :name => "Swedish Krona", :symbol => "kr", :subunit => "Öre", :subunit_to_unit => "100" },
155
- :sgd => { :priority => 100, :iso_code => "SGD", :name => "Singapore Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
156
- :shp => { :priority => 100, :iso_code => "SHP", :name => "Saint Helenian Pound", :symbol => "£", :subunit => "Penny", :subunit_to_unit => "100" },
157
- :skk => { :priority => 100, :iso_code => "SKK", :name => "Slovak Koruna", :symbol => "Sk", :subunit => "Halier", :subunit_to_unit => "100" },
158
- :sll => { :priority => 100, :iso_code => "SLL", :name => "Sierra Leonean Leone", :symbol => "Le", :subunit => "Cent", :subunit_to_unit => "100" },
159
- :sos => { :priority => 100, :iso_code => "SOS", :name => "Somali Shilling", :symbol => "Sh", :subunit => "Cent", :subunit_to_unit => "100" },
160
- :srd => { :priority => 100, :iso_code => "SRD", :name => "Surinamese Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
161
- :std => { :priority => 100, :iso_code => "STD", :name => "São Tomé and Príncipe Dobra", :symbol => "Db", :subunit => "Cêntimo", :subunit_to_unit => "100" },
162
- :svc => { :priority => 100, :iso_code => "SVC", :name => "Salvadoran Colón", :symbol => "₡", :subunit => "Centavo", :subunit_to_unit => "100" },
163
- :syp => { :priority => 100, :iso_code => "SYP", :name => "Syrian Pound", :symbol => "£ or ل.س", :subunit => "Piastre", :subunit_to_unit => "100" },
164
- :szl => { :priority => 100, :iso_code => "SZL", :name => "Swazi Lilangeni", :symbol => "L", :subunit => "Cent", :subunit_to_unit => "100" },
165
- :thb => { :priority => 100, :iso_code => "THB", :name => "Thai Baht", :symbol => "฿", :subunit => "Satang", :subunit_to_unit => "100" },
166
- :tjs => { :priority => 100, :iso_code => "TJS", :name => "Tajikistani Somoni", :symbol => "ЅМ", :subunit => "Diram", :subunit_to_unit => "100" },
167
- :tmm => { :priority => 100, :iso_code => "TMM", :name => "Turkmenistani Manat", :symbol => "m", :subunit => "Tennesi", :subunit_to_unit => "100" },
168
- :tnd => { :priority => 100, :iso_code => "TND", :name => "Tunisian Dinar", :symbol => "د.ت", :subunit => "Millime", :subunit_to_unit => "1,000" },
169
- :top => { :priority => 100, :iso_code => "TOP", :name => "Tongan Paʻanga", :symbol => "T$", :subunit => "Seniti", :subunit_to_unit => "100" },
170
- :try => { :priority => 100, :iso_code => "TRY", :name => "Turkish New Lira", :symbol => "YTL", :subunit => "New kuruş", :subunit_to_unit => "100" },
171
- :try => { :priority => 100, :iso_code => "TRY", :name => "Turkish New Lira", :symbol => "₤", :subunit => "New kuruş", :subunit_to_unit => "100" },
172
- :ttd => { :priority => 100, :iso_code => "TTD", :name => "Trinidad and Tobago Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
173
- :twd => { :priority => 100, :iso_code => "TWD", :name => "New Taiwan Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
174
- :tzs => { :priority => 100, :iso_code => "TZS", :name => "Tanzanian Shilling", :symbol => "Sh", :subunit => "Cent", :subunit_to_unit => "100" },
175
- :uah => { :priority => 100, :iso_code => "UAH", :name => "Ukrainian Hryvnia", :symbol => "₴", :subunit => "Kopiyka", :subunit_to_unit => "100" },
176
- :ugx => { :priority => 100, :iso_code => "UGX", :name => "Ugandan Shilling", :symbol => "Sh", :subunit => "Cent", :subunit_to_unit => "100" },
177
- :usd => { :priority => 1, :iso_code => "USD", :name => "United States Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
178
- :uyu => { :priority => 100, :iso_code => "UYU", :name => "Uruguayan Peso", :symbol => "$", :subunit => "Centésimo", :subunit_to_unit => "100" },
179
- :uzs => { :priority => 100, :iso_code => "UZS", :name => "Uzbekistani Som", :symbol => nil, :subunit => "Tiyin", :subunit_to_unit => "100" },
180
- :vef => { :priority => 100, :iso_code => "VEF", :name => "Venezuelan Bolívar", :symbol => "Bs F", :subunit => "Céntimo", :subunit_to_unit => "100" },
181
- :vnd => { :priority => 100, :iso_code => "VND", :name => "Vietnamese Đồng", :symbol => "₫", :subunit => "Hào", :subunit_to_unit => "10" },
182
- :vuv => { :priority => 100, :iso_code => "VUV", :name => "Vanuatu Vatu", :symbol => "Vt", :subunit => nil, :subunit_to_unit => nil },
183
- :wst => { :priority => 100, :iso_code => "WST", :name => "Samoan Tala", :symbol => "T", :subunit => "Sene", :subunit_to_unit => "100" },
184
- :xaf => { :priority => 100, :iso_code => "XAF", :name => "Central African Cfa Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => "100" },
185
- :xcd => { :priority => 100, :iso_code => "XCD", :name => "East Caribbean Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
186
- :xof => { :priority => 100, :iso_code => "XOF", :name => "West African Cfa Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => "100" },
187
- :xpf => { :priority => 100, :iso_code => "XPF", :name => "Cfp Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => "100" },
188
- :yer => { :priority => 100, :iso_code => "YER", :name => "Yemeni Rial", :symbol => "﷼", :subunit => "Fils", :subunit_to_unit => "100" },
189
- :zar => { :priority => 100, :iso_code => "ZAR", :name => "South African Rand", :symbol => "R", :subunit => "Cent", :subunit_to_unit => "100" },
190
- :zmk => { :priority => 100, :iso_code => "ZMK", :name => "Zambian Kwacha", :symbol => "ZK", :subunit => "Ngwee", :subunit_to_unit => "100" },
191
- :zwd => { :priority => 100, :iso_code => "ZWD", :name => "Zimbabwean Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" },
29
+ :aed => { :priority => 100, :iso_code => "AED", :name => "United Arab Emirates Dirham", :symbol => "د.إ", :subunit => "Fils", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
30
+ :afn => { :priority => 100, :iso_code => "AFN", :name => "Afghan Afghani", :symbol => "؋", :subunit => "Pul", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
31
+ :all => { :priority => 100, :iso_code => "ALL", :name => "Albanian Lek", :symbol => "L", :subunit => "Qintar", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
32
+ :amd => { :priority => 100, :iso_code => "AMD", :name => "Armenian Dram", :symbol => "դր.", :subunit => "Luma", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
33
+ :ang => { :priority => 100, :iso_code => "ANG", :name => "Netherlands Antillean Gulden", :symbol => "ƒ", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
34
+ :aoa => { :priority => 100, :iso_code => "AOA", :name => "Angolan Kwanza", :symbol => "Kz", :subunit => "Cêntimo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
35
+ :ars => { :priority => 100, :iso_code => "ARS", :name => "Argentine Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
36
+ :aud => { :priority => 4, :iso_code => "AUD", :name => "Australian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
37
+ :awg => { :priority => 100, :iso_code => "AWG", :name => "Aruban Florin", :symbol => "ƒ", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
38
+ :azn => { :priority => 100, :iso_code => "AZN", :name => "Azerbaijani Manat", :symbol => nil, :subunit => "Qəpik", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
39
+ :bam => { :priority => 100, :iso_code => "BAM", :name => "Bosnia and Herzegovina Convertible Mark", :symbol => "KM or КМ", :subunit => "Fening", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
40
+ :bbd => { :priority => 100, :iso_code => "BBD", :name => "Barbadian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
41
+ :bdt => { :priority => 100, :iso_code => "BDT", :name => "Bangladeshi Taka", :symbol => "৳", :subunit => "Paisa", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
42
+ :bgn => { :priority => 100, :iso_code => "BGN", :name => "Bulgarian Lev", :symbol => "лв", :subunit => "Stotinka", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
43
+ :bhd => { :priority => 100, :iso_code => "BHD", :name => "Bahraini Dinar", :symbol => "ب.د", :subunit => "Fils", :subunit_to_unit => 1000, :separator => ".", :delimiter => "," },
44
+ :bif => { :priority => 100, :iso_code => "BIF", :name => "Burundian Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
45
+ :bmd => { :priority => 100, :iso_code => "BMD", :name => "Bermudian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
46
+ :bnd => { :priority => 100, :iso_code => "BND", :name => "Brunei Dollar", :symbol => "$", :subunit => "Sen", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
47
+ :bob => { :priority => 100, :iso_code => "BOB", :name => "Bolivian Boliviano", :symbol => "Bs.", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
48
+ :brl => { :priority => 100, :iso_code => "BRL", :name => "Brazilian Real", :symbol => "R$ ", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ",", :delimiter => "." },
49
+ :bsd => { :priority => 100, :iso_code => "BSD", :name => "Bahamian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
50
+ :btn => { :priority => 100, :iso_code => "BTN", :name => "Bhutanese Ngultrum", :symbol => nil, :subunit => "Chertrum", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
51
+ :bwp => { :priority => 100, :iso_code => "BWP", :name => "Botswana Pula", :symbol => "P", :subunit => "Thebe", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
52
+ :byr => { :priority => 100, :iso_code => "BYR", :name => "Belarusian Ruble", :symbol => "Br", :subunit => "Kapyeyka", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
53
+ :bzd => { :priority => 100, :iso_code => "BZD", :name => "Belize Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
54
+ :cad => { :priority => 5, :iso_code => "CAD", :name => "Canadian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
55
+ :cdf => { :priority => 100, :iso_code => "CDF", :name => "Congolese Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
56
+ :chf => { :priority => 100, :iso_code => "CHF", :name => "Swiss Franc", :symbol => "Fr", :subunit => "Rappen", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
57
+ :chf => { :priority => 100, :iso_code => "CHF", :name => "Swiss Franc", :symbol => "Fr", :subunit => "Rappen", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
58
+ :clp => { :priority => 100, :iso_code => "CLP", :name => "Chilean Peso", :symbol => "$", :subunit => "Peso", :subunit_to_unit => 1, :separator => ",", :delimiter => "." },
59
+ :cny => { :priority => 100, :iso_code => "CNY", :name => "Chinese Renminbi Yuan", :symbol => "¥", :subunit => "Jiao", :subunit_to_unit => 10, :separator => ".", :delimiter => "," },
60
+ :cop => { :priority => 100, :iso_code => "COP", :name => "Colombian Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
61
+ :crc => { :priority => 100, :iso_code => "CRC", :name => "Costa Rican Colón", :symbol => "₡", :subunit => "Céntimo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
62
+ :cuc => { :priority => 100, :iso_code => "CUC", :name => "Cuban Convertible Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
63
+ :cup => { :priority => 100, :iso_code => "CUP", :name => "Cuban Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
64
+ :cve => { :priority => 100, :iso_code => "CVE", :name => "Cape Verdean Escudo", :symbol => "$ or Esc", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
65
+ :czk => { :priority => 100, :iso_code => "CZK", :name => "Czech Koruna", :symbol => "Kč", :subunit => "Haléř", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
66
+ :djf => { :priority => 100, :iso_code => "DJF", :name => "Djiboutian Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
67
+ :dkk => { :priority => 100, :iso_code => "DKK", :name => "Danish Krone", :symbol => "kr", :subunit => "Øre", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
68
+ :dop => { :priority => 100, :iso_code => "DOP", :name => "Dominican Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
69
+ :dzd => { :priority => 100, :iso_code => "DZD", :name => "Algerian Dinar", :symbol => "د.ج", :subunit => "Centime", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
70
+ :eek => { :priority => 100, :iso_code => "EEK", :name => "Estonian Kroon", :symbol => "KR", :subunit => "Sent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
71
+ :egp => { :priority => 100, :iso_code => "EGP", :name => "Egyptian Pound", :symbol => "£ or ج.م", :subunit => "Piastre", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
72
+ :ern => { :priority => 100, :iso_code => "ERN", :name => "Eritrean Nakfa", :symbol => "Nfk", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
73
+ :etb => { :priority => 100, :iso_code => "ETB", :name => "Ethiopian Birr", :symbol => nil, :subunit => "Santim", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
74
+ :eur => { :priority => 2, :iso_code => "EUR", :name => "Euro", :symbol => "€", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
75
+ :fjd => { :priority => 100, :iso_code => "FJD", :name => "Fijian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
76
+ :fkp => { :priority => 100, :iso_code => "FKP", :name => "Falkland Pound", :symbol => "£", :subunit => "Penny", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
77
+ :gbp => { :priority => 3, :iso_code => "GBP", :name => "British Pound", :symbol => "£", :subunit => "Penny", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
78
+ :gel => { :priority => 100, :iso_code => "GEL", :name => "Georgian Lari", :symbol => "ლ", :subunit => "Tetri", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
79
+ :ghc => { :priority => 100, :iso_code => "GHC", :name => "Ghanaian Cedi", :symbol => "₵", :subunit => "Pesewa", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
80
+ :gip => { :priority => 100, :iso_code => "GIP", :name => "Gibraltar Pound", :symbol => "£", :subunit => "Penny", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
81
+ :gmd => { :priority => 100, :iso_code => "GMD", :name => "Gambian Dalasi", :symbol => "D", :subunit => "Butut", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
82
+ :gnf => { :priority => 100, :iso_code => "GNF", :name => "Guinean Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
83
+ :gtq => { :priority => 100, :iso_code => "GTQ", :name => "Guatemalan Quetzal", :symbol => "Q", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
84
+ :gyd => { :priority => 100, :iso_code => "GYD", :name => "Guyanese Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
85
+ :hkd => { :priority => 100, :iso_code => "HKD", :name => "Hong Kong Dollar", :symbol => "$", :subunit => "Ho", :subunit_to_unit => 10, :separator => ".", :delimiter => "," },
86
+ :hnl => { :priority => 100, :iso_code => "HNL", :name => "Honduran Lempira", :symbol => "L", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
87
+ :hrk => { :priority => 100, :iso_code => "HRK", :name => "Croatian Kuna", :symbol => "kn", :subunit => "Lipa", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
88
+ :htg => { :priority => 100, :iso_code => "HTG", :name => "Haitian Gourde", :symbol => "G", :subunit => "Centime", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
89
+ :huf => { :priority => 100, :iso_code => "HUF", :name => "Hungarian Forint", :symbol => "Ft", :subunit => "Fillér", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
90
+ :idr => { :priority => 100, :iso_code => "IDR", :name => "Indonesian Rupiah", :symbol => "Rp", :subunit => "Sen", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
91
+ :ils => { :priority => 100, :iso_code => "ILS", :name => "Israeli New Sheqel", :symbol => "₪", :subunit => "Agora", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
92
+ :inr => { :priority => 100, :iso_code => "INR", :name => "Indian Rupee", :symbol => "₨", :subunit => "Paisa", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
93
+ :iqd => { :priority => 100, :iso_code => "IQD", :name => "Iraqi Dinar", :symbol => "ع.د", :subunit => "Fils", :subunit_to_unit => 1000, :separator => ".", :delimiter => "," },
94
+ :irr => { :priority => 100, :iso_code => "IRR", :name => "Iranian Rial", :symbol => "﷼", :subunit => "Dinar", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
95
+ :isk => { :priority => 100, :iso_code => "ISK", :name => "Icelandic Króna", :symbol => "kr", :subunit => "Eyrir", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
96
+ :jmd => { :priority => 100, :iso_code => "JMD", :name => "Jamaican Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
97
+ :jod => { :priority => 100, :iso_code => "JOD", :name => "Jordanian Dinar", :symbol => "د.ا", :subunit => "Piastre", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
98
+ :jpy => { :priority => 6, :iso_code => "JPY", :name => "Japanese Yen", :symbol => "¥", :subunit => "Sen", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
99
+ :kes => { :priority => 100, :iso_code => "KES", :name => "Kenyan Shilling", :symbol => "Sh", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
100
+ :kgs => { :priority => 100, :iso_code => "KGS", :name => "Kyrgyzstani Som", :symbol => nil, :subunit => "Tyiyn", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
101
+ :khr => { :priority => 100, :iso_code => "KHR", :name => "Cambodian Riel", :symbol => "៛", :subunit => "Sen", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
102
+ :kmf => { :priority => 100, :iso_code => "KMF", :name => "Comorian Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
103
+ :kpw => { :priority => 100, :iso_code => "KPW", :name => "North Korean Won", :symbol => "₩", :subunit => "Chŏn", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
104
+ :krw => { :priority => 100, :iso_code => "KRW", :name => "South Korean Won", :symbol => "₩", :subunit => "Jeon", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
105
+ :kwd => { :priority => 100, :iso_code => "KWD", :name => "Kuwaiti Dinar", :symbol => "د.ك", :subunit => "Fils", :subunit_to_unit => 1000, :separator => ".", :delimiter => "," },
106
+ :kyd => { :priority => 100, :iso_code => "KYD", :name => "Cayman Islands Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
107
+ :kzt => { :priority => 100, :iso_code => "KZT", :name => "Kazakhstani Tenge", :symbol => "〒", :subunit => "Tiyn", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
108
+ :lak => { :priority => 100, :iso_code => "LAK", :name => "Lao Kip", :symbol => "₭", :subunit => "Att", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
109
+ :lbp => { :priority => 100, :iso_code => "LBP", :name => "Lebanese Lira", :symbol => "ل.ل", :subunit => "Piastre", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
110
+ :lkr => { :priority => 100, :iso_code => "LKR", :name => "Sri Lankan Rupee", :symbol => "₨", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
111
+ :lrd => { :priority => 100, :iso_code => "LRD", :name => "Liberian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
112
+ :lsl => { :priority => 100, :iso_code => "LSL", :name => "Lesotho Loti", :symbol => "L", :subunit => "Sente", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
113
+ :ltl => { :priority => 100, :iso_code => "LTL", :name => "Lithuanian Litas", :symbol => "Lt", :subunit => "Centas", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
114
+ :lvl => { :priority => 100, :iso_code => "LVL", :name => "Latvian Lats", :symbol => "Ls", :subunit => "Santīms", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
115
+ :lyd => { :priority => 100, :iso_code => "LYD", :name => "Libyan Dinar", :symbol => "ل.د", :subunit => "Dirham", :subunit_to_unit => 1000, :separator => ".", :delimiter => "," },
116
+ :mad => { :priority => 100, :iso_code => "MAD", :name => "Moroccan Dirham", :symbol => "د.م.", :subunit => "Centime", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
117
+ :mdl => { :priority => 100, :iso_code => "MDL", :name => "Moldovan Leu", :symbol => "L", :subunit => "Ban", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
118
+ :mga => { :priority => 100, :iso_code => "MGA", :name => "Malagasy Ariary", :symbol => nil, :subunit => "Iraimbilanja", :subunit_to_unit => 5, :separator => ".", :delimiter => "," },
119
+ :mkd => { :priority => 100, :iso_code => "MKD", :name => "Macedonian Denar", :symbol => "ден", :subunit => "Deni", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
120
+ :mmk => { :priority => 100, :iso_code => "MMK", :name => "Myanmar Kyat", :symbol => "K", :subunit => "Pya", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
121
+ :mnt => { :priority => 100, :iso_code => "MNT", :name => "Mongolian Tögrög", :symbol => "₮", :subunit => "Möngö", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
122
+ :mop => { :priority => 100, :iso_code => "MOP", :name => "Macanese Pataca", :symbol => "P", :subunit => "Avo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
123
+ :mro => { :priority => 100, :iso_code => "MRO", :name => "Mauritanian Ouguiya", :symbol => "UM", :subunit => "Khoums", :subunit_to_unit => 5, :separator => ".", :delimiter => "," },
124
+ :mur => { :priority => 100, :iso_code => "MUR", :name => "Mauritian Rupee", :symbol => "₨", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
125
+ :mvr => { :priority => 100, :iso_code => "MVR", :name => "Maldivian Rufiyaa", :symbol => "ރ.", :subunit => "Laari", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
126
+ :mwk => { :priority => 100, :iso_code => "MWK", :name => "Malawian Kwacha", :symbol => "MK", :subunit => "Tambala", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
127
+ :mxn => { :priority => 100, :iso_code => "MXN", :name => "Mexican Peso", :symbol => "$", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
128
+ :myr => { :priority => 100, :iso_code => "MYR", :name => "Malaysian Ringgit", :symbol => "RM", :subunit => "Sen", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
129
+ :mzn => { :priority => 100, :iso_code => "MZN", :name => "Mozambican Metical", :symbol => "MTn", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
130
+ :nad => { :priority => 100, :iso_code => "NAD", :name => "Namibian Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
131
+ :ngn => { :priority => 100, :iso_code => "NGN", :name => "Nigerian Naira", :symbol => "₦", :subunit => "Kobo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
132
+ :nio => { :priority => 100, :iso_code => "NIO", :name => "Nicaraguan Córdoba", :symbol => "C$", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
133
+ :nok => { :priority => 100, :iso_code => "NOK", :name => "Norwegian Krone", :symbol => "kr", :subunit => "Øre", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
134
+ :npr => { :priority => 100, :iso_code => "NPR", :name => "Nepalese Rupee", :symbol => "₨", :subunit => "Paisa", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
135
+ :nzd => { :priority => 100, :iso_code => "NZD", :name => "New Zealand Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
136
+ :omr => { :priority => 100, :iso_code => "OMR", :name => "Omani Rial", :symbol => "ر.ع.", :subunit => "Baisa", :subunit_to_unit => 1000, :separator => ".", :delimiter => "," },
137
+ :pab => { :priority => 100, :iso_code => "PAB", :name => "Panamanian Balboa", :symbol => "B/.", :subunit => "Centésimo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
138
+ :pen => { :priority => 100, :iso_code => "PEN", :name => "Peruvian Nuevo Sol", :symbol => "S/.", :subunit => "Céntimo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
139
+ :pgk => { :priority => 100, :iso_code => "PGK", :name => "Papua New Guinean Kina", :symbol => "K", :subunit => "Toea", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
140
+ :php => { :priority => 100, :iso_code => "PHP", :name => "Philippine Peso", :symbol => "₱", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
141
+ :pkr => { :priority => 100, :iso_code => "PKR", :name => "Pakistani Rupee", :symbol => "₨", :subunit => "Paisa", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
142
+ :pln => { :priority => 100, :iso_code => "PLN", :name => "Polish Złoty", :symbol => "zł", :subunit => "Grosz", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
143
+ :pyg => { :priority => 100, :iso_code => "PYG", :name => "Paraguayan Guaraní", :symbol => "₲", :subunit => "Céntimo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
144
+ :qar => { :priority => 100, :iso_code => "QAR", :name => "Qatari Riyal", :symbol => "ر.ق", :subunit => "Dirham", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
145
+ :ron => { :priority => 100, :iso_code => "RON", :name => "Romanian Leu", :symbol => "L", :subunit => "Ban", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
146
+ :rsd => { :priority => 100, :iso_code => "RSD", :name => "Serbian Dinar", :symbol => "din. or дин.", :subunit => "Para", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
147
+ :rub => { :priority => 100, :iso_code => "RUB", :name => "Russian Ruble", :symbol => "р.", :subunit => "Kopek", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
148
+ :rub => { :priority => 100, :iso_code => "RUB", :name => "Russian Ruble", :symbol => "руб.", :subunit => "Kopek", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
149
+ :rwf => { :priority => 100, :iso_code => "RWF", :name => "Rwandan Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
150
+ :sar => { :priority => 100, :iso_code => "SAR", :name => "Saudi Riyal", :symbol => "ر.س", :subunit => "Hallallah", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
151
+ :sbd => { :priority => 100, :iso_code => "SBD", :name => "Solomon Islands Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
152
+ :scr => { :priority => 100, :iso_code => "SCR", :name => "Seychellois Rupee", :symbol => "₨", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
153
+ :sdg => { :priority => 100, :iso_code => "SDG", :name => "Sudanese Pound", :symbol => "£", :subunit => "Piastre", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
154
+ :sek => { :priority => 100, :iso_code => "SEK", :name => "Swedish Krona", :symbol => "kr", :subunit => "Öre", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
155
+ :sgd => { :priority => 100, :iso_code => "SGD", :name => "Singapore Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
156
+ :shp => { :priority => 100, :iso_code => "SHP", :name => "Saint Helenian Pound", :symbol => "£", :subunit => "Penny", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
157
+ :skk => { :priority => 100, :iso_code => "SKK", :name => "Slovak Koruna", :symbol => "Sk", :subunit => "Halier", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
158
+ :sll => { :priority => 100, :iso_code => "SLL", :name => "Sierra Leonean Leone", :symbol => "Le", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
159
+ :sos => { :priority => 100, :iso_code => "SOS", :name => "Somali Shilling", :symbol => "Sh", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
160
+ :srd => { :priority => 100, :iso_code => "SRD", :name => "Surinamese Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
161
+ :std => { :priority => 100, :iso_code => "STD", :name => "São Tomé and Príncipe Dobra", :symbol => "Db", :subunit => "Cêntimo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
162
+ :svc => { :priority => 100, :iso_code => "SVC", :name => "Salvadoran Colón", :symbol => "₡", :subunit => "Centavo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
163
+ :syp => { :priority => 100, :iso_code => "SYP", :name => "Syrian Pound", :symbol => "£ or ل.س", :subunit => "Piastre", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
164
+ :szl => { :priority => 100, :iso_code => "SZL", :name => "Swazi Lilangeni", :symbol => "L", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
165
+ :thb => { :priority => 100, :iso_code => "THB", :name => "Thai Baht", :symbol => "฿", :subunit => "Satang", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
166
+ :tjs => { :priority => 100, :iso_code => "TJS", :name => "Tajikistani Somoni", :symbol => "ЅМ", :subunit => "Diram", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
167
+ :tmm => { :priority => 100, :iso_code => "TMM", :name => "Turkmenistani Manat", :symbol => "m", :subunit => "Tennesi", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
168
+ :tnd => { :priority => 100, :iso_code => "TND", :name => "Tunisian Dinar", :symbol => "د.ت", :subunit => "Millime", :subunit_to_unit => 1000, :separator => ".", :delimiter => "," },
169
+ :top => { :priority => 100, :iso_code => "TOP", :name => "Tongan Paʻanga", :symbol => "T$", :subunit => "Seniti", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
170
+ :try => { :priority => 100, :iso_code => "TRY", :name => "Turkish New Lira", :symbol => "YTL", :subunit => "New kuruş", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
171
+ :try => { :priority => 100, :iso_code => "TRY", :name => "Turkish New Lira", :symbol => "₤", :subunit => "New kuruş", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
172
+ :ttd => { :priority => 100, :iso_code => "TTD", :name => "Trinidad and Tobago Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
173
+ :twd => { :priority => 100, :iso_code => "TWD", :name => "New Taiwan Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
174
+ :tzs => { :priority => 100, :iso_code => "TZS", :name => "Tanzanian Shilling", :symbol => "Sh", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
175
+ :uah => { :priority => 100, :iso_code => "UAH", :name => "Ukrainian Hryvnia", :symbol => "₴", :subunit => "Kopiyka", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
176
+ :ugx => { :priority => 100, :iso_code => "UGX", :name => "Ugandan Shilling", :symbol => "Sh", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
177
+ :usd => { :priority => 1, :iso_code => "USD", :name => "United States Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
178
+ :uyu => { :priority => 100, :iso_code => "UYU", :name => "Uruguayan Peso", :symbol => "$", :subunit => "Centésimo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
179
+ :uzs => { :priority => 100, :iso_code => "UZS", :name => "Uzbekistani Som", :symbol => nil, :subunit => "Tiyin", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
180
+ :vef => { :priority => 100, :iso_code => "VEF", :name => "Venezuelan Bolívar", :symbol => "Bs F", :subunit => "Céntimo", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
181
+ :vnd => { :priority => 100, :iso_code => "VND", :name => "Vietnamese Đồng", :symbol => "₫", :subunit => "Hào", :subunit_to_unit => 10, :separator => ".", :delimiter => "," },
182
+ :vuv => { :priority => 100, :iso_code => "VUV", :name => "Vanuatu Vatu", :symbol => "Vt", :subunit => nil, :subunit_to_unit => 1, :separator => ".", :delimiter => "," },
183
+ :wst => { :priority => 100, :iso_code => "WST", :name => "Samoan Tala", :symbol => "T", :subunit => "Sene", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
184
+ :xaf => { :priority => 100, :iso_code => "XAF", :name => "Central African Cfa Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
185
+ :xcd => { :priority => 100, :iso_code => "XCD", :name => "East Caribbean Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
186
+ :xof => { :priority => 100, :iso_code => "XOF", :name => "West African Cfa Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
187
+ :xpf => { :priority => 100, :iso_code => "XPF", :name => "Cfp Franc", :symbol => "Fr", :subunit => "Centime", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
188
+ :yer => { :priority => 100, :iso_code => "YER", :name => "Yemeni Rial", :symbol => "﷼", :subunit => "Fils", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
189
+ :zar => { :priority => 100, :iso_code => "ZAR", :name => "South African Rand", :symbol => "R", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
190
+ :zmk => { :priority => 100, :iso_code => "ZMK", :name => "Zambian Kwacha", :symbol => "ZK", :subunit => "Ngwee", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
191
+ :zwd => { :priority => 100, :iso_code => "ZWD", :name => "Zimbabwean Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
192
192
 
193
193
  # aliases for BC with documentation before Currency
194
- :yen => { :priority => 100, :iso_code => "JPY", :name => "Japanese Yen", :symbol => "¥", :subunit => "Sen", :subunit_to_unit => "100" },
194
+ :yen => { :priority => 100, :iso_code => "JPY", :name => "Japanese Yen", :symbol => "¥", :subunit => "Sen", :subunit_to_unit => 100, :separator => ".", :delimiter => "," },
195
195
  }
196
196
 
197
197
  attr_reader :id, *ATTRIBUTES
@@ -44,14 +44,14 @@ class Money
44
44
  # Everything else defaults to '$'
45
45
  }, "Money::SYMBOLS has no longer effect. See Money::Currency#symbol.")
46
46
 
47
- SEPARATORS = {
47
+ SEPARATORS = DeprecatedHash.new({
48
48
  "BRL" => ",",
49
49
  # Everything else defaults to '.'
50
- }
50
+ }, "Money::SEPARATORS is deprecated. See Money::Currency#separator.")
51
51
 
52
- DELIMITERS = {
52
+ DELIMITERS = DeprecatedHash.new({
53
53
  "BRL" => ".",
54
54
  # Everything else defaults to ","
55
- }
55
+ }, "Money::DELIMITERS is deprecated. See Money::Currency#delimiter.")
56
56
 
57
57
  end
@@ -237,20 +237,16 @@ class Money
237
237
  currency.symbol || "$"
238
238
  end
239
239
 
240
- # Attempts to pick a delimiter that's suitable for the given currency
241
- # looking up the Money::DELIMITERS hashtable.
242
- # If the symbol for the given currency isn't known,
243
- # then it will default to ",".
240
+ # Uses :delimiter from the Currency hash. If it is not specified defaults to
241
+ # ",".
244
242
  def delimiter
245
- DELIMITERS[currency.to_s] || ","
243
+ currency.delimiter || ","
246
244
  end
247
245
 
248
- # Attempts to pick a separator for <tt>cents</tt> that's suitable for the given currency
249
- # looking up the Money::DELIMITERS hashtable.
250
- # If the separator for the given currency isn't known,
251
- # then it will default to ".".
246
+ # Uses :separator from the Currency Hash. If it is not specified defaults to
247
+ # ".".
252
248
  def separator
253
- SEPARATORS[currency.to_s] || "."
249
+ currency.separator || "."
254
250
  end
255
251
 
256
252
  # Creates a formatted price string according to several rules. The following
@@ -377,10 +373,10 @@ class Money
377
373
  symbol_value = symbol
378
374
  end
379
375
 
380
- if rules[:no_cents]
381
- formatted = sprintf("#{symbol_value}%d", cents.to_f / 100)
376
+ if rules[:no_cents] or currency.subunit_to_unit == 1
377
+ formatted = sprintf("#{symbol_value}%d", cents.to_f / currency.subunit_to_unit)
382
378
  else
383
- formatted = sprintf("#{symbol_value}%.2f", cents.to_f / 100)
379
+ formatted = sprintf("#{symbol_value}%.2f", cents.to_f / currency.subunit_to_unit)
384
380
  end
385
381
 
386
382
  delimiter_value = delimiter
@@ -419,7 +415,8 @@ class Money
419
415
  # Money.ca_dollar(100).to_s => "1.00"
420
416
  #
421
417
  def to_s
422
- sprintf("%.2f", cents / 100.00)
418
+ return sprintf("%d", cents) if currency.subunit_to_unit == 1
419
+ sprintf("%.2f", cents.to_f / currency.subunit_to_unit)
423
420
  end
424
421
 
425
422
  # Return the amount of money as a float. Floating points cannot guarantee
@@ -430,7 +427,7 @@ class Money
430
427
  # Money.us_dollar(100).to_f => 1.0
431
428
  #
432
429
  def to_f
433
- cents / 100.0
430
+ cents.to_f / currency.subunit_to_unit
434
431
  end
435
432
 
436
433
  # Receive the amount of this money object in another Currency.
@@ -65,7 +65,7 @@ class Money
65
65
  if !rate
66
66
  raise Money::UnknownRate, "No conversion rate known for '#{from_currency}' -> '#{to_currency}'"
67
67
  end
68
- (cents * rate).floor
68
+ (cents * rate).to_s.to_i
69
69
  end
70
70
 
71
71
  @@singleton = VariableExchangeBank.new
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{money}
8
- s.version = "3.0.3"
8
+ s.version = "3.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tobias Luetke", "Hongli Lai", "Jeremy McNevin", "Shane Emmons"]
12
- s.date = %q{2010-06-21}
12
+ s.date = %q{2010-06-24}
13
13
  s.description = %q{Money and currency exchange support library.}
14
14
  s.email = %q{hongli@phusion.nl}
15
15
  s.extra_rdoc_files = [
@@ -10,14 +10,16 @@ describe Money::Currency do
10
10
 
11
11
  specify "#initialize should lookup data from TABLE" do
12
12
  with_custom_definitions do
13
- Money::Currency::TABLE[:usd] = { :priority => 1, :iso_code => "USD", :name => "United States Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" }
14
- Money::Currency::TABLE[:eur] = { :priority => 2, :iso_code => "EUR", :name => "Euro", :symbol => "€", :subunit => "Cent", :subunit_to_unit => "100" }
13
+ Money::Currency::TABLE[:usd] = { :priority => 1, :iso_code => "USD", :name => "United States Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," }
14
+ Money::Currency::TABLE[:eur] = { :priority => 2, :iso_code => "EUR", :name => "Euro", :symbol => "€", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," }
15
15
 
16
16
  currency = Money::Currency.new("USD")
17
17
  currency.id.should == :usd
18
18
  currency.priority.should == 1
19
19
  currency.iso_code.should == "USD"
20
20
  currency.name.should == "United States Dollar"
21
+ currency.separator.should == "."
22
+ currency.delimiter.should == ","
21
23
  end
22
24
  end
23
25
 
@@ -47,14 +49,14 @@ describe Money::Currency do
47
49
 
48
50
  specify "#inspect" do
49
51
  Money::Currency.new(:usd).inspect.should ==
50
- %Q{#<Money::Currency id: usd priority: 1, iso_code: USD, name: United States Dollar, symbol: $, subunit: Cent, subunit_to_unit: 100>}
52
+ %Q{#<Money::Currency id: usd priority: 1, iso_code: USD, name: United States Dollar, symbol: $, subunit: Cent, subunit_to_unit: 100, separator: ., delimiter: ,>}
51
53
  end
52
54
 
53
55
 
54
56
  specify "#self.find should return currency matching given id" do
55
57
  with_custom_definitions do
56
- Money::Currency::TABLE[:usd] = { :priority => 1, :iso_code => "USD", :name => "United States Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" }
57
- Money::Currency::TABLE[:eur] = { :priority => 2, :iso_code => "EUR", :name => "Euro", :symbol => "€", :subunit => "Cent", :subunit_to_unit => "100" }
58
+ Money::Currency::TABLE[:usd] = { :priority => 1, :iso_code => "USD", :name => "United States Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," }
59
+ Money::Currency::TABLE[:eur] = { :priority => 2, :iso_code => "EUR", :name => "Euro", :symbol => "€", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," }
58
60
 
59
61
  expected = Money::Currency.new(:eur)
60
62
  Money::Currency.find(:eur).should == expected
@@ -66,8 +68,8 @@ describe Money::Currency do
66
68
 
67
69
  specify "#self.find should return nil unless currency matching given id" do
68
70
  with_custom_definitions do
69
- Money::Currency::TABLE[:usd] = { :position => 1, :iso_code => "USD", :name => "United States Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => "100" }
70
- Money::Currency::TABLE[:eur] = { :position => 2, :iso_code => "EUR", :name => "Euro", :symbol => "€", :subunit => "Cent", :subunit_to_unit => "100" }
71
+ Money::Currency::TABLE[:usd] = { :position => 1, :iso_code => "USD", :name => "United States Dollar", :symbol => "$", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," }
72
+ Money::Currency::TABLE[:eur] = { :position => 2, :iso_code => "EUR", :name => "Euro", :symbol => "€", :subunit => "Cent", :subunit_to_unit => 100, :separator => ".", :delimiter => "," }
71
73
 
72
74
  expected = Money::Currency.new(:eur)
73
75
  Money::Currency.find(:eur).should == expected
@@ -42,4 +42,20 @@ describe Money::VariableExchangeBank do
42
42
  block = lambda { @bank.exchange(10, "USD", "EUR") }
43
43
  block.should raise_error(Money::UnknownRate)
44
44
  end
45
+
46
+ describe '.exchange' do
47
+ context 'sterling to euros using a rate of 1.39' do
48
+ it 'returns the correct amount' do
49
+ @bank.add_rate('GBP', 'EUR', 1.38)
50
+ @bank.exchange(10000, 'GBP', 'EUR').should == 13800
51
+ end
52
+ end
53
+
54
+ context 'dollars to euros using a rate of 0.86' do
55
+ it 'returns the correct amount' do
56
+ @bank.add_rate('USD', 'EUR', 0.86)
57
+ @bank.exchange(10000, 'USD', 'EUR').should == 8600
58
+ end
59
+ end
60
+ end
45
61
  end
@@ -463,15 +463,35 @@ describe Money do
463
463
  Money.new(10_00).to_s.should == "10.00"
464
464
  end
465
465
 
466
+ specify "Money.to_s works with :subunit_to_unit other than 100" do
467
+ Money.new(10_00, "BHD").to_s.should == "1.00"
468
+ end
469
+
470
+ specify "Money.to_s shouldn't have decimal when :subunit_to_unit is 1" do
471
+ Money.new(10_00, "CLP").to_s.should == "1000"
472
+ end
473
+
466
474
  specify "Money.to_f works" do
467
475
  Money.new(10_00).to_f.should == 10.0
468
476
  end
469
477
 
478
+ specify "Money.to_f works with :subunit_to_unit other than 100" do
479
+ Money.new(10_00, "BHD").to_f.should == 1.0
480
+ end
481
+
470
482
  describe "#format" do
471
483
  it "returns the monetary value as a string" do
472
484
  Money.ca_dollar(100).format.should == "$1.00"
473
485
  end
474
486
 
487
+ it "uses the correct :subunit_to_unit" do
488
+ Money.new(10_00, "BHD").format.should == "ب.د1.00"
489
+ end
490
+
491
+ it "doesn't display a decimal when :subunit_to_unit is 1" do
492
+ Money.new(10_00, "CLP").format.should == "$1.000"
493
+ end
494
+
475
495
  specify "respects the delimiter and separator defaults" do
476
496
  one_thousand = Proc.new do |currency|
477
497
  Money.new(1000_00, currency).format
@@ -489,7 +509,7 @@ describe Money do
489
509
 
490
510
  # Yen
491
511
  one_thousand["JPY"].should == "¥1,000.00"
492
- one_thousand["CNY"].should == "¥1,000.00"
512
+ one_thousand["CNY"].should == "¥10,000.00"
493
513
 
494
514
  # Euro
495
515
  one_thousand["EUR"].should == "€1,000.00"
@@ -540,35 +560,15 @@ describe Money do
540
560
  end
541
561
 
542
562
  specify "#delimiter works as documented" do
543
- begin
544
- old = Money::DELIMITERS.dup
545
- Money::DELIMITERS.clear
546
- Money::DELIMITERS["EUR"] = "."
547
-
548
- Money.empty("EUR").delimiter.should == "."
549
- Money.empty("USD").delimiter.should == ","
550
- Money.empty("GBP").delimiter.should == ","
551
- ensure
552
- silence_warnings do
553
- Money::DELIMITERS = old
554
- end
555
- end
563
+ Money.empty("USD").delimiter.should == ","
564
+ Money.empty("EUR").delimiter.should == ","
565
+ Money.empty("BRL").delimiter.should == "."
556
566
  end
557
567
 
558
568
  specify "#separator works as documented" do
559
- begin
560
- old = Money::SEPARATORS.dup
561
- Money::SEPARATORS.clear
562
- Money::SEPARATORS["EUR"] = "_"
563
-
564
- Money.empty("EUR").separator.should == "_"
565
- Money.empty("USD").separator.should == "."
566
- Money.empty("GBP").separator.should == "."
567
- ensure
568
- silence_warnings do
569
- Money::SEPARATORS = old
570
- end
571
- end
569
+ Money.empty("USD").separator.should == "."
570
+ Money.empty("EUR").separator.should == "."
571
+ Money.empty("BRL").separator.should == ","
572
572
  end
573
573
 
574
574
  specify "#format(:with_currency => true) works as documented" do
@@ -589,6 +589,10 @@ describe Money do
589
589
  Money.ca_dollar(39000).format(:no_cents => true).should == "$390"
590
590
  end
591
591
 
592
+ specify "#format(:no_cents => true) uses correct :subunit_to_unit" do
593
+ Money.new(10_00, "BHD").format(:no_cents => true).should == "ب.د1"
594
+ end
595
+
592
596
  specify "#format(:no_cents) works as documented" do
593
597
  Money.ca_dollar(100).format(:no_cents).should == "$1"
594
598
  Money.ca_dollar(599).format(:no_cents).should == "$5"
@@ -596,6 +600,10 @@ describe Money do
596
600
  Money.ca_dollar(39000).format(:no_cents).should == "$390"
597
601
  end
598
602
 
603
+ specify "#format(:no_cents) uses correct :subunit_to_unit" do
604
+ Money.new(10_00, "BHD").format(:no_cents).should == "ب.د1"
605
+ end
606
+
599
607
  specify "#format(:symbol => a symbol string) uses the given value as the money symbol" do
600
608
  Money.new(100, "GBP").format(:symbol => "£").should == "£1.00"
601
609
  end
@@ -617,7 +625,7 @@ describe Money do
617
625
 
618
626
  # Yen
619
627
  one["JPY"].should == "¥1.00"
620
- one["CNY"].should == "¥1.00"
628
+ one["CNY"].should == "¥10.00"
621
629
 
622
630
  # Euro
623
631
  one["EUR"].should == "€1.00"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 3
10
- version: 3.0.3
9
+ - 4
10
+ version: 3.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tobias Luetke
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-06-21 00:00:00 -04:00
21
+ date: 2010-06-24 00:00:00 -04:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency