Skip to content

Commit b676d90

Browse files
committed
README 💅
1 parent 4766542 commit b676d90

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ The development version (hosted on Github) can be installed with:
5454

5555
## Usage
5656

57-
``` ruby
57+
```ruby
5858
require 'money'
5959

6060
# explicitly define locales
@@ -102,15 +102,15 @@ Currencies are consistently represented as instances of `Money::Currency`.
102102
The most part of `Money` APIs allows you to supply either a `String` or a
103103
`Money::Currency`.
104104

105-
``` ruby
105+
```ruby
106106
Money.from_cents(1000, "USD") == Money.from_cents(1000, Money::Currency.new("USD"))
107107
Money.from_cents(1000, "EUR").currency == Money::Currency.new("EUR")
108108
```
109109

110110
A `Money::Currency` instance holds all the information about the currency,
111111
including the currency symbol, name and much more.
112112

113-
``` ruby
113+
```ruby
114114
currency = Money.from_cents(1000, "USD").currency
115115
currency.iso_code #=> "USD"
116116
currency.name #=> "United States Dollar"
@@ -120,7 +120,7 @@ currency.cents_based? #=> true
120120
To define a new `Money::Currency` use `Money::Currency.register` as shown
121121
below.
122122

123-
``` ruby
123+
```ruby
124124
curr = {
125125
priority: 1,
126126
iso_code: "USD",
@@ -164,7 +164,7 @@ selector like the one available
164164
custom methods to return the list of major currencies and all currencies as
165165
follows:
166166

167-
``` ruby
167+
```ruby
168168
# Returns an array of currency id where
169169
# priority < 10
170170
def major_currencies(hash)
@@ -194,7 +194,7 @@ all_currencies(Money::Currency.table)
194194

195195
A 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
198198
Money.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
208208
information. You can find the exponent (as an `Integer`) by
209209

210-
``` ruby
210+
```ruby
211211
Money::Currency.new("USD").exponent # => 2
212212
Money::Currency.new("JPY").exponent # => 0
213213
Money::Currency.new("MGA").exponent # => 1
@@ -217,7 +217,7 @@ Money::Currency.new("MGA").exponent # => 1
217217

218218
To find a given currency by ISO 4217 numeric code (three digits) you can do
219219

220-
``` ruby
220+
```ruby
221221
Money::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
227227
exchange bank object requires one to manually specify the exchange rate. Here's
228228
an example of how it works:
229229

230-
``` ruby
230+
```ruby
231231
Money.add_rate("USD", "CAD", 1.24515)
232232
Money.add_rate("CAD", "USD", 0.803115)
233233

@@ -237,7 +237,7 @@ Money.ca_dollar(100).exchange_to("USD") # => Money.from_cents(80, "USD")
237237

238238
Comparison and arithmetic operations work as expected:
239239

240-
``` ruby
240+
```ruby
241241
Money.from_cents(1000, "USD") <=> Money.from_cents(900, "USD") # => 1; 9.00 USD is smaller
242242
Money.from_cents(1000, "EUR") + Money.from_cents(10, "EUR") == Money.from_cents(1010, "EUR")
243243

@@ -345,7 +345,6 @@ end
345345
The following example implements a `Redis` store to save exchange rates to a redis database.
346346
347347
```ruby
348-
349348
class RedisRateStore
350349
INDEX_KEY_SEPARATOR = '_TO_'.freeze
351350

@@ -409,7 +408,7 @@ Money.from_cents(1000, 'USD').exchange_to('CAD') #=> #<Money fractional:900 curr
409408
There 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
413412
Money.default_bank = Money::Bank::VariableExchange.new(StoreWhichScrapesXeDotCom.new)
414413
```
415414

@@ -423,7 +422,7 @@ Money.default_bank = MyCustomBank.new(Money::RatesStore::Memory.new)
423422
If you wish to disable automatic currency conversion to prevent arithmetic when
424423
currencies don't match:
425424

426-
``` ruby
425+
```ruby
427426
Money.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

605604
Set the following:
606-
``` ruby
605+
```ruby
607606
I18n.enforce_available_locales = false
608607
```
609608

0 commit comments

Comments
 (0)