Class: Get_Weather_Icon

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

Instance Method Summary collapse

Instance Method Details

#run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/Get_Weather_Icon/get_weather_icon.rb', line 7

def run(params)
  agent = Mechanize.new
  agent.get("http://weather.yahoo.com/forecast/USVA0262.html")
  icon = agent.page.at(".forecast-icon")
  style = icon.attributes["style"].value
  icon_url = style.split("'")[1]

  rio(icon_url) > rio("/tmp/weather-icon.png")
end