Class: Thunderwear::GetWeather

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

Instance Method Summary collapse

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

#currentlyObject



30
31
32
# File 'lib/thunderwear.rb', line 30

def currently
  local_weather.currently.apparentTemperature
end

#local_weatherObject



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

#starsObject



38
39
40
# File 'lib/thunderwear.rb', line 38

def stars
  "*" * (today.length + 28)
end

#todayObject



34
35
36
# File 'lib/thunderwear.rb', line 34

def today
  local_weather.daily.summary
end

#townObject



20
21
22
# File 'lib/thunderwear.rb', line 20

def town
  Geocoder.address(@zip)
end

#weather_meObject



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

#zippocoderObject



16
17
18
# File 'lib/thunderwear.rb', line 16

def zippocoder
  Geocoder.coordinates(@zip)
end