Class: Scraper

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#forecastObject (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_nowObject



12
13
14
# File 'lib/models/scraper.rb', line 12

def get_temp_now
  @scraped_content.css('span.temperature-fahrenheit')
end

#get_temp_tomorrowObject



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_yesterdayObject



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