class MasonellwoodCliAppTwo::CLI attr_accessor :state_info 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 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" ] 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" every_state.each_with_index do |the_state, index| index += 1 puts "#{index}. #{the_state.capitalize}" end puts "Here are all the valid States, which one would you like to know the weather?" elsif every_state.include?(state) == false && state != "states" && 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 citys = city.split(/ : /) puts "#{index}: #{citys[0]}" end display_city_weather end def display_city_weather puts "Now type the name of the city you want to know the weather of." input = nil array = [] @state_info.cities.each_with_index.each do |city, index| index += 1 city = city.split(/ : /) array << city[0].downcase end while input != "exit" input = gets.strip.downcase if input == "cities" @state_info.cities.each_with_index.each do |city, index| index += 1 city = city.split(/ : /) puts "#{index}: #{city[0]}" end puts "Now type the name of the city you want to know the weather of." elsif array.include?(input) @state_info.city_weather(input) elsif input != "exit" puts "Please type a valid city, or type exit." end end end def another_state puts "would you like to check a different state? Type yes or no." input = nil input = gets.strip.downcase case input when "yes" set_up_instance_variable when "no" goodbye else puts "Please type yes or no" end end def goodbye puts "See you tomorrow for more weather reports!" end end