Class: CurrencyConverter::XE

Inherits:
Object
  • Object
show all
Defined in:
lib/currency_converter/xe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#from_currencyObject (readonly)

Returns the Symbol of ‘from’ currency



9
10
11
# File 'lib/currency_converter/xe.rb', line 9

def from_currency
  @from_currency
end

#to_currencyObject (readonly)

Returns the Symbol of ‘to’ currency



12
13
14
# File 'lib/currency_converter/xe.rb', line 12

def to_currency
  @to_currency
end

Instance Method Details

#exchange(from, to, fixnum) ⇒ amount

Receive the amount of you desire currency.

currency_converter = CurrencyConverter::XE.new currency_converter.exchange(‘USD’, ‘EUR’, 100) currency_converter.exchange(‘USD’, ‘INR’, 100)

Parameters:

  • other (String, String, Numeric)

    currency to exchange to.

Returns:

  • (amount)


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/currency_converter/xe.rb', line 24

def exchange(from, to, fixnum)
  @from_currency = from.upcase.to_sym
  @to_currency = to.upcase.to_sym

  validate_currency

  ex_rate = exchange_rate

  validate_rate(ex_rate)

  ex_rate.to_f * fixnum
end