Module: Mint::FixerCurrency

Defined in:
lib/mint/fixer_currency.rb,
lib/mint/fixer_currency/request.rb,
lib/mint/fixer_currency/version.rb,
lib/mint/fixer_currency/exceptions.rb

Overview

Access to foreign exchange rates from Fixer.io

Defined Under Namespace

Classes: FixerArgumentError, Request, WrongCurrencyError

Constant Summary collapse

VERSION =
'0.1.0'.freeze

Class Method Summary collapse

Class Method Details

.currenciesArray<Symbols>

List of available currencies

Returns:

  • (Array<Symbols>)


24
25
26
27
# File 'lib/mint/fixer_currency.rb', line 24

def self.currencies
  %i[AUD BGN BRL CAD CHF CNY CZK DKK GBP HKD HRK HUF IDR ILS INR JPY KRW MXN MYR NOK NZD PHP PLN RON RUB
     SEK SGD TRY USD ZAR EUR]
end

.rates(currency = :USD, date = nil) ⇒ Hash

Gets you currency exchange rates

Parameters:

  • currency (Symbol, String) (defaults to: :USD)

    based currency

  • date (String) (defaults to: nil)

    YYYY-MM-DD optional date or latest by default

Returns:

  • (Hash)

Raises:



16
17
18
19
20
# File 'lib/mint/fixer_currency.rb', line 16

def self.rates(currency = :USD, date = nil)
  currency = currency.to_s.upcase.to_sym
  raise(WrongCurrencyError, currency) unless currencies.include? currency
  Request.new(currency, date).perform!
end