Class: WeatherLookup::CLI

Inherits:
Object
  • Object
show all
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

#callObject



15
16
17
18
# File 'lib/weather_lookup/cli.rb', line 15

def call
  welcome_greeting
  get_zip
end

#get_zipObject



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_line_bar
      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_line_bar
      puts "Would you like to look up another zip or exit?"
      puts_line_bar
    elsif input == "exit"
      puts_line_bar
      puts "goodbye!"
      puts_line_bar
    else
      puts_line_bar
      puts Paint["Try again, Zip must be 5 numbers.", "red"]
      puts Paint["or exit by inputing exit", "red"]
      puts_line_bar
    end
  end
end

#welcome_greetingObject



20
21
22
23
24
25
26
27
# File 'lib/weather_lookup/cli.rb', line 20

def welcome_greeting
  puts_line_bar
  puts Paint["Welcome to Weather Lookup", PRIMARY_COLOR]
  puts Paint["The current season is #{current_season}", DARK_COLOR]
  puts_line_bar
  puts "Enter a zipcode: "
  puts_line_bar
end