Class: Scraper
- Inherits:
-
Object
- Object
- Scraper
- Defined in:
- lib/models/scraper.rb
Instance Attribute Summary collapse
-
#forecast ⇒ Object
readonly
Returns the value of attribute forecast.
Instance Method Summary collapse
- #get_temp_now ⇒ Object
- #get_temp_tomorrow ⇒ Object
- #get_temp_yesterday ⇒ Object
-
#initialize(scrape_target) ⇒ Scraper
constructor
A new instance of Scraper.
Constructor Details
#initialize(scrape_target) ⇒ Scraper
Returns a new instance of Scraper.
4 5 6 |
# File 'lib/models/scraper.rb', line 4 def initialize(scrape_target) @scraped_content = Nokogiri::HTML(open(scrape_target)) end |
Instance Attribute Details
#forecast ⇒ Object (readonly)
Returns the value of attribute forecast.
2 3 4 |
# File 'lib/models/scraper.rb', line 2 def forecast @forecast end |
Instance Method Details
#get_temp_now ⇒ Object
12 13 14 |
# File 'lib/models/scraper.rb', line 12 def get_temp_now @scraped_content.css('span.temperature-fahrenheit') end |
#get_temp_tomorrow ⇒ Object
16 17 18 |
# File 'lib/models/scraper.rb', line 16 def get_temp_tomorrow @scraped_content.css('p.wx-temp').text.strip[0..1].to_i end |
#get_temp_yesterday ⇒ Object
8 9 10 |
# File 'lib/models/scraper.rb', line 8 def get_temp_yesterday @scraped_content.css('p.wx-temp').text.strip[0..1].to_i end |