Class: Thunderwear::GetWeather
- Inherits:
-
Object
- Object
- Thunderwear::GetWeather
- Defined in:
- lib/thunderwear.rb
Instance Method Summary collapse
- #currently ⇒ Object
-
#initialize(zip) ⇒ GetWeather
constructor
A new instance of GetWeather.
- #local_weather ⇒ Object
- #stars ⇒ Object
- #today ⇒ Object
- #town ⇒ Object
- #weather_me ⇒ Object
- #zippocoder ⇒ Object
Constructor Details
#initialize(zip) ⇒ GetWeather
Returns a new instance of GetWeather.
9 10 11 |
# File 'lib/thunderwear.rb', line 9 def initialize(zip) @zip = zip end |
Instance Method Details
#currently ⇒ Object
29 30 31 |
# File 'lib/thunderwear.rb', line 29 def currently local_weather.currently.apparentTemperature end |
#local_weather ⇒ Object
23 24 25 26 27 |
# File 'lib/thunderwear.rb', line 23 def local_weather lat = zippocoder.first long = zippocoder.last ForecastIO.forecast(lat, long) end |
#stars ⇒ Object
37 38 39 |
# File 'lib/thunderwear.rb', line 37 def stars "*" * (today.length + 28) end |
#today ⇒ Object
33 34 35 |
# File 'lib/thunderwear.rb', line 33 def today local_weather.daily.summary end |
#town ⇒ Object
19 20 21 |
# File 'lib/thunderwear.rb', line 19 def town Geocoder.address(@zip) end |
#weather_me ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/thunderwear.rb', line 41 def weather_me puts stars puts "Weather for #{town}".colorize(:blue) puts "\n\t - current temperature: ".colorize(:blue) + "#{currently.to_s.colorize(:green)}" puts "\t - today's summary:".colorize(:blue) + " #{today.colorize(:green)}\n\n" puts stars end |
#zippocoder ⇒ Object
15 16 17 |
# File 'lib/thunderwear.rb', line 15 def zippocoder Geocoder.coordinates(@zip) end |