Class: Danconia::Exchanges::BNA
- Inherits:
-
Danconia::Exchange
- Object
- Danconia::Exchange
- Danconia::Exchanges::BNA
- Defined in:
- lib/danconia/exchanges/bna.rb
Overview
The BNA does not provide an API to pull the rates, so this implementation scrapes the home HTML directly. Returns rates of both types, “Billetes” and “Divisas”, and only the “tipo de cambio vendedor” ones. See `examples/bna.rb` for a complete usage example.
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #fetch_rates ⇒ Object
-
#initialize(store: Stores::InMemory.new) ⇒ BNA
constructor
A new instance of BNA.
- #rates(rate_type:, date: nil) ⇒ Object
- #update_rates! ⇒ Object
Methods inherited from Danconia::Exchange
Constructor Details
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
11 12 13 |
# File 'lib/danconia/exchanges/bna.rb', line 11 def store @store end |
Instance Method Details
#fetch_rates ⇒ Object
17 18 19 20 |
# File 'lib/danconia/exchanges/bna.rb', line 17 def fetch_rates response = Net::HTTP.get URI 'https://www.bna.com.ar/Personas' scrape_rates(response, 'billetes') + scrape_rates(response, 'divisas') end |
#rates(rate_type:, date: nil) ⇒ Object
26 27 28 |
# File 'lib/danconia/exchanges/bna.rb', line 26 def rates rate_type:, date: nil array_of_rates_to_hash @store.rates(rate_type: rate_type, date: date) end |
#update_rates! ⇒ Object
22 23 24 |
# File 'lib/danconia/exchanges/bna.rb', line 22 def update_rates! @store.save_rates fetch_rates end |