Class: Umbrella::Weather
- Inherits:
-
Object
- Object
- Umbrella::Weather
- Defined in:
- lib/Umbrella/weather.rb
Instance Attribute Summary collapse
-
#rain_perc ⇒ Object
Returns the value of attribute rain_perc.
-
#sunrise ⇒ Object
Returns the value of attribute sunrise.
-
#sunset ⇒ Object
Returns the value of attribute sunset.
-
#temperature ⇒ Object
Returns the value of attribute temperature.
-
#weather_condition ⇒ Object
Returns the value of attribute weather_condition.
-
#wind ⇒ Object
Returns the value of attribute wind.
Class Method Summary collapse
Instance Attribute Details
#rain_perc ⇒ Object
Returns the value of attribute rain_perc.
2 3 4 |
# File 'lib/Umbrella/weather.rb', line 2 def rain_perc @rain_perc end |
#sunrise ⇒ Object
Returns the value of attribute sunrise.
2 3 4 |
# File 'lib/Umbrella/weather.rb', line 2 def sunrise @sunrise end |
#sunset ⇒ Object
Returns the value of attribute sunset.
2 3 4 |
# File 'lib/Umbrella/weather.rb', line 2 def sunset @sunset end |
#temperature ⇒ Object
Returns the value of attribute temperature.
2 3 4 |
# File 'lib/Umbrella/weather.rb', line 2 def temperature @temperature end |
#weather_condition ⇒ Object
Returns the value of attribute weather_condition.
2 3 4 |
# File 'lib/Umbrella/weather.rb', line 2 def weather_condition @weather_condition end |
#wind ⇒ Object
Returns the value of attribute wind.
2 3 4 |
# File 'lib/Umbrella/weather.rb', line 2 def wind @wind end |
Class Method Details
.weather_setter(location_url) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/Umbrella/weather.rb', line 4 def self.weather_setter(location_url) doc = Nokogiri::HTML(open("https://weather.com/weather/today/l/#{location_url}")) rain = self.new rain.temperature = doc.search("div.today_nowcard-temp").text rain.weather_condition = doc.search("div.today_nowcard-phrase").text rain.wind = doc.search("div.today_nowcard-sidecar").search("td")[0].text rain.sunrise = doc.search("span.wx-dsxdate")[0].text rain.sunset = doc.search("span.wx-dsxdate")[1].text rain.rain_perc = doc.search("span.precip-val").first.text rain end |