class MasonellwoodCliAppTwo::CLI attr_accessor :state_info EVERY_STATE = ["alabama", "alaska", "arizona", "arkansas", "california", "colorado", "connecticut", "delaware", "florida", "georgia", "hawaii", "idaho", "illinois", "indiana", "iowa", "kansas", "kentucky", "louisiana", "maine", "maryland", "massachusetts", "michigan", "minnesota", "mississippi", "missouri", "montana", "nebraska", "nevada", "new hampshire", "new jersey", "new mexico", "new york", "north carolina", "north dakota", "ohio", "oklahoma", "oregon", "pennsylvania", "rhode island", "south carolina", "south dakota", "tennessee", "texas", "utah", "vermont", "virginia", "washington", "west virginia", "wisconsin", "wyoming" ] def call greet_with_prompt set_up_instance_variable goodbye end def greet_with_prompt puts "Welcome to your local Weather Channel!" end def set_up_instance_variable puts "Please type your State of interest." puts "If you forgot how to spell some of the state names, just type states." puts "If you don't care about the weather today, just type exit." state = nil while state != "exit" state = gets.strip.downcase if EVERY_STATE.include?(state) @state_info = MasonellwoodCliAppTwo::StateScraper.new(state) @state_info.scrape_cities display_citie_option puts "Are you sure you don't want to check the weather of a different state?" puts "Like before: type States, the State name, or simply type exit." elsif state == "states" || state == "States" || state == "STATES" EVERY_STATE.each_with_index do |state, index| index += 1 puts "#{index}. #{state.capitalize}" end puts "Here are all the valid States, which one would you like to know the weather?" elsif state != "exit" puts "Not sure what you want bud. Please type exit to quit. Or see the valid states by typing states." end end end def display_citie_option puts "Awesome! It looks like you are interested in #{@state_info.state.capitalize}!" puts "Here are all of the cities in #{@state_info.state.capitalize}!" @state_info.cities.each_with_index.each do |city, index| index += 1 puts "#{index}: #{city.name}" end display_city_weather end def display_city_weather puts "Enter the number of the city you want to view" input = nil while input != "exit" input = gets.strip.downcase if input == "cities" @state_info.cities.each_with_index.each do |city, index| index += 1 puts "#{index}: #{city.name}" end puts "Now type the name of the city you want to know the weather of." elsif input.to_i.between?(1, @state_info.cities.size) city = @state_info.cities[input.to_i - 1] @state_info.city_weather(city) elsif input != "exit" puts "Please type a valid city, or type exit." end end end def goodbye puts "See you tomorrow for more weather reports!" end end