class ParseData::WeatherChannelHourly
Attributes
html[RW]
Public Class Methods
new(doc)
click to toggle source
# File lib/parse_data.rb, line 267 def initialize(doc) self.html = Nokogiri::HTML(doc) end
Public Instance Methods
days()
click to toggle source
# File lib/parse_data.rb, line 335 def days self.html.css('tbody div.hourly-date').collect do |day| day.text end end
feels()
click to toggle source
# File lib/parse_data.rb, line 305 def feels values('feels') end
humidities()
click to toggle source
# File lib/parse_data.rb, line 319 def humidities items = values('humidity') items.each do |item| if item.length < 2 items.delete(item) end end items end
names()
click to toggle source
# File lib/parse_data.rb, line 284 def names days.zip(times).collect do |day, time| "#{time}".gsub(' ', '') end end
precips()
click to toggle source
# File lib/parse_data.rb, line 309 def precips items = values('precip') items.each do |item| if item.length < 2 items.delete(item) end end items end
return_hash()
click to toggle source
# File lib/parse_data.rb, line 271 def return_hash names.collect.with_index do |name, i| { :day => name, :current_temp => temps[i], :feels_like => feels[i], :wind_magnitude => winds[i], :humidity => humidities[i], :precipitation => precips[i], :short_detail => short_details[i] } end end
short_details()
click to toggle source
# File lib/parse_data.rb, line 296 def short_details a = values('hidden-cell-sm.description') a end
temps()
click to toggle source
# File lib/parse_data.rb, line 301 def temps values('temp') end
times()
click to toggle source
# File lib/parse_data.rb, line 329 def times self.html.css('tbody div.hourly-time span').collect do |time| time.text end end
values(value)
click to toggle source
# File lib/parse_data.rb, line 290 def values(value) self.html.css("tbody td.#{value} span").collect do |item| item.text end end
winds()
click to toggle source
# File lib/parse_data.rb, line 341 def winds values('wind') end