Class: ParseData::WeatherChannelToday
- Inherits:
-
Object
- Object
- ParseData::WeatherChannelToday
- Defined in:
- lib/parse_data.rb
Instance Attribute Summary collapse
-
#html ⇒ Object
Returns the value of attribute html.
Instance Method Summary collapse
- #current_temp ⇒ Object
- #feels_like ⇒ Object
- #humidity ⇒ Object
-
#initialize(doc) ⇒ WeatherChannelToday
constructor
A new instance of WeatherChannelToday.
- #long_detail ⇒ Object
- #max ⇒ Object
- #min ⇒ Object
- #panel0_precip ⇒ Object
- #panel0_short_detail ⇒ Object
- #panel0_temp ⇒ Object
- #panel0_text ⇒ Object
- #panel1_precip ⇒ Object
- #panel1_short_detail ⇒ Object
- #panel1_temp ⇒ Object
- #panel1_text ⇒ Object
- #panel2_precip ⇒ Object
- #panel2_short_detail ⇒ Object
- #panel2_temp ⇒ Object
- #panel2_text ⇒ Object
- #return_hash ⇒ Object
- #sunrise ⇒ Object
- #sunset ⇒ Object
- #uv_index ⇒ Object
- #wind ⇒ Object
- #wind_direction ⇒ Object
- #wind_magnitude ⇒ Object
- #wind_units ⇒ Object
- #wx_detail ⇒ Object
Constructor Details
#initialize(doc) ⇒ WeatherChannelToday
Returns a new instance of WeatherChannelToday.
129 130 131 |
# File 'lib/parse_data.rb', line 129 def initialize(doc) self.html = Nokogiri::HTML(doc) end |
Instance Attribute Details
#html ⇒ Object
Returns the value of attribute html.
127 128 129 |
# File 'lib/parse_data.rb', line 127 def html @html end |
Instance Method Details
#current_temp ⇒ Object
163 164 165 |
# File 'lib/parse_data.rb', line 163 def current_temp self.html.css('div.today_nowcard div.today_nowcard-temp span').text end |
#feels_like ⇒ Object
159 160 161 |
# File 'lib/parse_data.rb', line 159 def feels_like self.html.css('div.today_nowcard div.today_nowcard-feels span.deg-feels').text end |
#humidity ⇒ Object
195 196 197 |
# File 'lib/parse_data.rb', line 195 def humidity wx_detail[1].text end |
#long_detail ⇒ Object
211 212 213 |
# File 'lib/parse_data.rb', line 211 def long_detail self.html.css('div.dp-details span#dp0-details-narrative').text end |
#max ⇒ Object
167 168 169 |
# File 'lib/parse_data.rb', line 167 def max self.html.css('div.today_nowcard-hilo span.deg-hilo-nowcard')[0].text end |
#min ⇒ Object
171 172 173 |
# File 'lib/parse_data.rb', line 171 def min self.html.css('div.today_nowcard-hilo span.deg-hilo-nowcard')[1].text end |
#panel0_precip ⇒ Object
215 216 217 |
# File 'lib/parse_data.rb', line 215 def panel0_precip self.html.css('div#daypart-0 span.precip-val').text end |
#panel0_short_detail ⇒ Object
227 228 229 |
# File 'lib/parse_data.rb', line 227 def panel0_short_detail self.html.css('div#daypart-0 span.today-daypart-wxphrase').text end |
#panel0_temp ⇒ Object
251 252 253 |
# File 'lib/parse_data.rb', line 251 def panel0_temp self.html.css('div#daypart-0 div.today-daypart-temp').text end |
#panel0_text ⇒ Object
239 240 241 |
# File 'lib/parse_data.rb', line 239 def panel0_text self.html.css('div#daypart-0 span.today-daypart-title').text end |
#panel1_precip ⇒ Object
219 220 221 |
# File 'lib/parse_data.rb', line 219 def panel1_precip self.html.css('div#daypart-1 span.precip-val').text end |
#panel1_short_detail ⇒ Object
231 232 233 |
# File 'lib/parse_data.rb', line 231 def panel1_short_detail self.html.css('div#daypart-1 span.today-daypart-wxphrase').text end |
#panel1_temp ⇒ Object
255 256 257 |
# File 'lib/parse_data.rb', line 255 def panel1_temp self.html.css('div#daypart-1 div.today-daypart-temp').text end |
#panel1_text ⇒ Object
243 244 245 |
# File 'lib/parse_data.rb', line 243 def panel1_text self.html.css('div#daypart-1 span.today-daypart-title').text end |
#panel2_precip ⇒ Object
223 224 225 |
# File 'lib/parse_data.rb', line 223 def panel2_precip self.html.css('div#daypart-2 span.precip-val').text end |
#panel2_short_detail ⇒ Object
235 236 237 |
# File 'lib/parse_data.rb', line 235 def panel2_short_detail self.html.css('div#daypart-2 span.today-daypart-wxphrase').text end |
#panel2_temp ⇒ Object
259 260 261 |
# File 'lib/parse_data.rb', line 259 def panel2_temp self.html.css('div#daypart-2 div.today-daypart-temp').text end |
#panel2_text ⇒ Object
247 248 249 |
# File 'lib/parse_data.rb', line 247 def panel2_text self.html.css('div#daypart-2 span.today-daypart-title').text end |
#return_hash ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/parse_data.rb', line 133 def return_hash { :day => panel0_text, :panel1_name => panel1_text, :panel2_name => panel2_text, :current_temp => current_temp, :panel1_temp => panel1_temp, :panel2_temp => panel2_temp, :short_detail => panel0_short_detail, :panel1_short_detail => panel1_short_detail, :panel2_short_detail => panel2_short_detail, :precipitation => panel0_precip, :panel1_precip => panel1_precip, :panel2_precip => panel2_precip, :max => max, :min => min, :wind_direction => wind_direction, :wind_magnitude => wind_magnitude, :wind_units => wind_units, :long_detail => long_detail, :humidity => humidity, :uv_index => uv_index, :sunrise => sunrise, :sunset => sunset, :feels_like => feels_like} end |
#sunrise ⇒ Object
203 204 205 |
# File 'lib/parse_data.rb', line 203 def sunrise wx_detail.css('span#dp0-details-sunrise').text.sub(' ', '') end |
#sunset ⇒ Object
207 208 209 |
# File 'lib/parse_data.rb', line 207 def sunset wx_detail.css('span#dp0-details-sunset').text.sub(' ', '') end |
#uv_index ⇒ Object
199 200 201 |
# File 'lib/parse_data.rb', line 199 def uv_index wx_detail[2].text.sub(' ', '') end |
#wind ⇒ Object
179 180 181 |
# File 'lib/parse_data.rb', line 179 def wind wx_detail[0].text end |
#wind_direction ⇒ Object
187 188 189 |
# File 'lib/parse_data.rb', line 187 def wind_direction wind.split(' ')[0] end |
#wind_magnitude ⇒ Object
191 192 193 |
# File 'lib/parse_data.rb', line 191 def wind_magnitude wind.split(' ')[1] end |
#wind_units ⇒ Object
183 184 185 |
# File 'lib/parse_data.rb', line 183 def wind_units wind.split(' ')[2] end |
#wx_detail ⇒ Object
175 176 177 |
# File 'lib/parse_data.rb', line 175 def wx_detail self.html.css('div.looking-ahead.panel-footer li.wx-detail span.wx-detail-text span.wx-detail-value') end |