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
30 31 32 |
# File 'lib/thunderwear.rb', line 30 def currently local_weather.currently.apparentTemperature end |
#local_weather ⇒ Object
24 25 26 27 28 |
# File 'lib/thunderwear.rb', line 24 def local_weather lat = zippocoder.first long = zippocoder.last ForecastIO.forecast(lat, long) end |
#stars ⇒ Object
38 39 40 |
# File 'lib/thunderwear.rb', line 38 def stars "*" * (today.length + 28) end |
#today ⇒ Object
34 35 36 |
# File 'lib/thunderwear.rb', line 34 def today local_weather.daily.summary end |
#town ⇒ Object
20 21 22 |
# File 'lib/thunderwear.rb', line 20 def town Geocoder.address(@zip) end |
#weather_me ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/thunderwear.rb', line 42 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
16 17 18 |
# File 'lib/thunderwear.rb', line 16 def zippocoder Geocoder.coordinates(@zip) end |