@@ -54,7 +54,7 @@ The development version (hosted on Github) can be installed with:
5454
5555## Usage
5656
57- ``` ruby
57+ ``` ruby
5858require ' money'
5959
6060# explicitly define locales
@@ -102,15 +102,15 @@ Currencies are consistently represented as instances of `Money::Currency`.
102102The most part of ` Money ` APIs allows you to supply either a ` String ` or a
103103` Money::Currency ` .
104104
105- ``` ruby
105+ ``` ruby
106106Money .from_cents(1000 , " USD" ) == Money .from_cents(1000 , Money ::Currency .new (" USD" ))
107107Money .from_cents(1000 , " EUR" ).currency == Money ::Currency .new (" EUR" )
108108```
109109
110110A ` Money::Currency ` instance holds all the information about the currency,
111111including the currency symbol, name and much more.
112112
113- ``` ruby
113+ ``` ruby
114114currency = Money .from_cents(1000 , " USD" ).currency
115115currency.iso_code # => "USD"
116116currency.name # => "United States Dollar"
@@ -120,7 +120,7 @@ currency.cents_based? #=> true
120120To define a new ` Money::Currency ` use ` Money::Currency.register ` as shown
121121below.
122122
123- ``` ruby
123+ ``` ruby
124124curr = {
125125 priority: 1 ,
126126 iso_code: " USD" ,
@@ -164,7 +164,7 @@ selector like the one available
164164custom methods to return the list of major currencies and all currencies as
165165follows:
166166
167- ``` ruby
167+ ``` ruby
168168# Returns an array of currency id where
169169# priority < 10
170170def major_currencies (hash )
@@ -194,7 +194,7 @@ all_currencies(Money::Currency.table)
194194
195195A default currency is not set by default. If a default currency is not set, it will raise an error when you try to initialize a ` Money ` object without explicitly passing a currency or parse a string that does not contain a currency. You can set a default currency for your application by using:
196196
197- ``` ruby
197+ ``` ruby
198198Money .default_currency = Money ::Currency .new (" CAD" )
199199```
200200
@@ -207,7 +207,7 @@ separator (which separates the major unit from the minor unit). See e.g.
207207[ ISO 4217] ( https://www.iso.org/iso-4217-currency-codes.html ) for more
208208information. You can find the exponent (as an ` Integer ` ) by
209209
210- ``` ruby
210+ ``` ruby
211211Money ::Currency .new (" USD" ).exponent # => 2
212212Money ::Currency .new (" JPY" ).exponent # => 0
213213Money ::Currency .new (" MGA" ).exponent # => 1
@@ -217,7 +217,7 @@ Money::Currency.new("MGA").exponent # => 1
217217
218218To find a given currency by ISO 4217 numeric code (three digits) you can do
219219
220- ``` ruby
220+ ``` ruby
221221Money ::Currency .find_by_iso_numeric(978 ) # => Money::Currency.new(:eur)
222222```
223223
@@ -227,7 +227,7 @@ Exchanging money is performed through an exchange bank object. The default
227227exchange bank object requires one to manually specify the exchange rate. Here's
228228an example of how it works:
229229
230- ``` ruby
230+ ``` ruby
231231Money .add_rate(" USD" , " CAD" , 1.24515 )
232232Money .add_rate(" CAD" , " USD" , 0.803115 )
233233
@@ -237,7 +237,7 @@ Money.ca_dollar(100).exchange_to("USD") # => Money.from_cents(80, "USD")
237237
238238Comparison and arithmetic operations work as expected:
239239
240- ``` ruby
240+ ``` ruby
241241Money .from_cents(1000 , " USD" ) <=> Money .from_cents(900 , " USD" ) # => 1; 9.00 USD is smaller
242242Money .from_cents(1000 , " EUR" ) + Money .from_cents(10 , " EUR" ) == Money .from_cents(1010 , " EUR" )
243243
345345The following example implements a ` Redis ` store to save exchange rates to a redis database.
346346
347347` ` ` ruby
348-
349348class RedisRateStore
350349 INDEX_KEY_SEPARATOR = ' _TO_' .freeze
351350
@@ -409,7 +408,7 @@ Money.from_cents(1000, 'USD').exchange_to('CAD') #=> #<Money fractional:900 curr
409408There is nothing stopping you from creating store objects which scrapes
410409[ XE] ( https://www.xe.com ) for the current rates or just returns ` rand(2) ` :
411410
412- ``` ruby
411+ ``` ruby
413412Money .default_bank = Money ::Bank ::VariableExchange .new (StoreWhichScrapesXeDotCom .new )
414413```
415414
@@ -423,7 +422,7 @@ Money.default_bank = MyCustomBank.new(Money::RatesStore::Memory.new)
423422If you wish to disable automatic currency conversion to prevent arithmetic when
424423currencies don't match:
425424
426- ``` ruby
425+ ``` ruby
427426Money .disallow_currency_conversion!
428427```
429428
@@ -603,7 +602,7 @@ If you don't have some locale and don't want to get a runtime error such as:
603602 I18n::InvalidLocale : :en is not a valid locale
604603
605604Set the following :
606- ` ` ` ruby
605+ ` ` ` ruby
607606I18n.enforce_available_locales = false
608607` ` `
609608
0 commit comments