Class: WeatherLookup::CLI
- Inherits:
-
Object
- Object
- WeatherLookup::CLI
- Defined in:
- lib/weather_lookup/cli.rb
Constant Summary collapse
- PRIMARY_COLOR =
sky blue
"5fcbf5"- SECONDARY_COLOR =
light blue
"2bafe3"- DARK_COLOR =
dark blue
"063175"
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
15 16 17 18 |
# File 'lib/weather_lookup/cli.rb', line 15 def call welcome_greeting get_zip end |
#get_zip ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/weather_lookup/cli.rb', line 29 def get_zip input = nil while input != "exit" input = gets.strip.downcase if zip_valid?(input) data = WeatherLookup::Weather.scrape_wunderground(input) puts Paint["#{data.location} #{data.zip}:", PRIMARY_COLOR] #Color is inbtween Primary and Dark Color puts Paint["#{data.time}", "4873b8"] #Color is inbtween Primary and Dark Color puts Paint["The Weather is #{data.weather}", "20498a"] puts Paint["Temperture: #{data.current_temp}°F", DARK_COLOR] puts "Would you like to look up another zip or exit?" elsif input == "exit" puts "goodbye!" else puts Paint["Try again, Zip must be 5 numbers.", "red"] puts Paint["or exit by inputing exit", "red"] end end end |
#welcome_greeting ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/weather_lookup/cli.rb', line 20 def welcome_greeting puts Paint["Welcome to Weather Lookup", PRIMARY_COLOR] puts Paint["The current season is #{current_season}", DARK_COLOR] puts "Enter a zipcode: " end |