Class: CurrencyQuote::Currency

Inherits:
Object
  • Object
show all
Defined in:
lib/currency_quote/currency.rb

Constant Summary collapse

BASE_URL =
"https://www.bcra.gob.ar/publicacionesestadisticas/Cotizaciones_por_fecha_2.asp"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(currency:, date:) ⇒ Currency

Returns a new instance of Currency.



10
11
12
13
14
# File 'lib/currency_quote/currency.rb', line 10

def initialize(currency:, date: )
  @currency = currency
  @date    = date
  @dolar     = dolar
end

Instance Attribute Details

#buyObject

Returns the value of attribute buy.



6
7
8
# File 'lib/currency_quote/currency.rb', line 6

def buy
  @buy
end

#currencyObject

Returns the value of attribute currency.



6
7
8
# File 'lib/currency_quote/currency.rb', line 6

def currency
  @currency
end

#dateObject

Returns the value of attribute date.



6
7
8
# File 'lib/currency_quote/currency.rb', line 6

def date
  @date
end

#docObject

Returns the value of attribute doc.



6
7
8
# File 'lib/currency_quote/currency.rb', line 6

def doc
  @doc
end

#dolarObject

Returns the value of attribute dolar.



6
7
8
# File 'lib/currency_quote/currency.rb', line 6

def dolar
  @dolar
end

#quoteObject

Returns the value of attribute quote.



6
7
8
# File 'lib/currency_quote/currency.rb', line 6

def quote
  @quote
end

#sellObject

Returns the value of attribute sell.



6
7
8
# File 'lib/currency_quote/currency.rb', line 6

def sell
  @sell
end

Instance Method Details

#get_quotationObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/currency_quote/currency.rb', line 16

def get_quotation
  begin
    get_dolar_quotation
    make_get_to_bcra
    get_currency_quotation
  rescue Timeout::Error => e
    @sell = @buy = @quote = 0
  end
  return struct
end