Class: ParseData::WeatherChannelToday

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#htmlObject

Returns the value of attribute html.



127
128
129
# File 'lib/parse_data.rb', line 127

def html
  @html
end

Instance Method Details

#current_tempObject



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_likeObject



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

#humidityObject



195
196
197
# File 'lib/parse_data.rb', line 195

def humidity
    wx_detail[1].text
end

#long_detailObject



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

#maxObject



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

#minObject



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_precipObject



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_detailObject



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_tempObject



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_textObject



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_precipObject



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_detailObject



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_tempObject



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_textObject



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_precipObject



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_detailObject



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_tempObject



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_textObject



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_hashObject



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

#sunriseObject



203
204
205
# File 'lib/parse_data.rb', line 203

def sunrise
    wx_detail.css('span#dp0-details-sunrise').text.sub(' ', '')
end

#sunsetObject



207
208
209
# File 'lib/parse_data.rb', line 207

def sunset
    wx_detail.css('span#dp0-details-sunset').text.sub(' ', '')
end

#uv_indexObject



199
200
201
# File 'lib/parse_data.rb', line 199

def uv_index
    wx_detail[2].text.sub(' ', '')
end

#windObject



179
180
181
# File 'lib/parse_data.rb', line 179

def wind
    wx_detail[0].text
end

#wind_directionObject



187
188
189
# File 'lib/parse_data.rb', line 187

def wind_direction
    wind.split(' ')[0]
end

#wind_magnitudeObject



191
192
193
# File 'lib/parse_data.rb', line 191

def wind_magnitude
    wind.split(' ')[1]
end

#wind_unitsObject



183
184
185
# File 'lib/parse_data.rb', line 183

def wind_units
    wind.split(' ')[2]
end

#wx_detailObject



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