Class: Tannenbaum::Scraper

Inherits:
Object
  • Object
show all
Defined in:
lib/tannenbaum/scraper.rb

Instance Method Summary collapse

Constructor Details

#initialize(supplier) ⇒ Scraper

A [Scraper] that fetches and parses the exchange rate data from our -for now- only [Provider].



7
8
9
10
# File 'lib/tannenbaum/scraper.rb', line 7

def initialize(supplier)
  @url = supplier.url
  @provider = supplier.provider
end

Instance Method Details

#processHash

Processes the XML response of our [Provider] and return it as a [Hash].

Returns:

  • (Hash)

    with fresh exchange rate data.



16
17
18
19
20
# File 'lib/tannenbaum/scraper.rb', line 16

def process
  xml_response = open(@url) rescue Hash.new
  quote = Nokogiri::XML(xml_response)
  parse_exchange_rates(quote)
end