Class: Dolar::Bna::Convert

Inherits:
Object
  • Object
show all
Defined in:
lib/dolar/bna/convert.rb

Instance Method Summary collapse

Constructor Details

#initialize(value = 0, conversion = "ars_to_usd", dolar_type = "Divisa", date = Date.today, aliquot = 0) ⇒ Convert

Returns a new instance of Convert.



4
5
6
7
8
9
10
# File 'lib/dolar/bna/convert.rb', line 4

def initialize(value=0, conversion="ars_to_usd", dolar_type="Divisa", date=Date.today, aliquot=0)
  @value ||= value
  @conversion ||= conversion
  @dolar_type ||= dolar_type
  @date ||= date
  @aliquot ||= aliquot
end

Instance Method Details

#performObject



12
13
14
15
16
17
18
19
20
# File 'lib/dolar/bna/convert.rb', line 12

def perform
  #dolar_query =  Dolar::Bna::DolarCotization.where(date: Date.today, dolar_type: @dolar_type).first
  dolar_buy, dolar_sell = set_dolar(@date)
  if @conversion == "ars_to_usd"
    ars_to_dolar(dolar_sell)
  else
    dolar_to_ars(dolar_buy)
  end
end