Class: JaredWeather
- Inherits:
-
Object
- Object
- JaredWeather
- Defined in:
- lib/jared-weather/cli.rb,
lib/jared-weather/version.rb,
lib/jared-weather/jared-weather.rb
Defined Under Namespace
Classes: CLI
Constant Summary collapse
- VERSION =
"1.0.0"
Instance Method Summary collapse
- #default ⇒ Object
- #forecast ⇒ Object
-
#initialize(place_or_zipcode) ⇒ JaredWeather
constructor
A new instance of JaredWeather.
- #notice ⇒ Object
- #today ⇒ Object
- #tomorrow ⇒ Object
- #weather ⇒ Object
Constructor Details
#initialize(place_or_zipcode) ⇒ JaredWeather
Returns a new instance of JaredWeather.
2 3 4 5 6 7 8 9 |
# File 'lib/jared-weather/jared-weather.rb', line 2 def initialize(place_or_zipcode) begin @weather = Weatherboy.new(place_or_zipcode) rescue => e puts "The error '#{e}', occurred fetching weather information." exit end end |
Instance Method Details
#default ⇒ Object
38 39 40 41 42 |
# File 'lib/jared-weather/jared-weather.rb', line 38 def default forecast = weather.current puts forecast.temp_f + "Degrees Fahrenheit.", forecast.weather + ".", forecast.wind_mph + " mile per hour winds from the #{forecast.wind_dir}." notice end |
#forecast ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/jared-weather/jared-weather.rb', line 15 def forecast weather.forecasts.each do |condition| puts "#{condition.title}." puts " #{condition.text}" puts end notice end |
#notice ⇒ Object
44 45 46 47 |
# File 'lib/jared-weather/jared-weather.rb', line 44 def notice puts puts "-- from Weather Underground - http://www.wunderground.com" end |
#today ⇒ Object
24 25 26 27 28 29 |
# File 'lib/jared-weather/jared-weather.rb', line 24 def today condition = weather.forecasts[0] puts "#{condition.title}." puts " #{condition.text}" notice end |
#tomorrow ⇒ Object
31 32 33 34 35 36 |
# File 'lib/jared-weather/jared-weather.rb', line 31 def tomorrow condition = weather.forecasts[2] puts "#{condition.title}." puts " #{condition.text}" notice end |
#weather ⇒ Object
11 12 13 |
# File 'lib/jared-weather/jared-weather.rb', line 11 def weather @weather end |