Class: Tannenbaum::Scraper
- Inherits:
-
Object
- Object
- Tannenbaum::Scraper
- Defined in:
- lib/tannenbaum/scraper.rb
Instance Method Summary collapse
-
#initialize(supplier) ⇒ Scraper
constructor
A [Scraper] that fetches and parses the exchange rate data from our -for now- only [Provider].
-
#process ⇒ Hash
Processes the XML response of our [Provider] and return it as a [Hash].
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
#process ⇒ Hash
Processes the XML response of our [Provider] and return it as a [Hash].
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 |