Class: Spree::Conekta::Exchange

Inherits:
Object
  • Object
show all
Defined in:
lib/spree/conekta/exchange.rb

Constant Summary collapse

EXCHANCE_SERVICES =
'https://currency-api.appspot.com/api/'

Instance Method Summary collapse

Constructor Details

#initialize(amount, currency_from) ⇒ Exchange

Returns a new instance of Exchange.



6
7
8
9
10
# File 'lib/spree/conekta/exchange.rb', line 6

def initialize(amount, currency_from)
  @amount = (amount.to_i)
  @currency_from = currency_from
  get_exchange_rate
end

Instance Method Details

#amount_exchangedObject



12
13
14
# File 'lib/spree/conekta/exchange.rb', line 12

def amount_exchanged
  @amount_exchanged ||= (@amount * @exchange_rate).round
end