Class: CurrencyConverter::XE
- Inherits:
-
Object
- Object
- CurrencyConverter::XE
- Defined in:
- lib/currency_converter/xe.rb
Instance Attribute Summary collapse
-
#from_currency ⇒ Object
readonly
Returns the Symbol of ‘from’ currency.
-
#to_currency ⇒ Object
readonly
Returns the Symbol of ‘to’ currency.
Instance Method Summary collapse
-
#exchange(from, to, fixnum) ⇒ amount
Receive the amount of you desire currency.
Instance Attribute Details
#from_currency ⇒ Object (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_currency ⇒ Object (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)
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 |