222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
# File 'lib/weatherpup/cli.rb', line 222
def fetch_previous
system "clear"
if WeatherPup::WeatherConditions.all == []
system "clear"
puts "\nThere are no previous fetches to display!".colorize(:cyan)
self.return_to_main_menu_prompt
system "clear"
else
puts "\n"
WeatherPup::WeatherConditions.list_all_previous
valid_input_range = 1..WeatherPup::WeatherConditions.all.length
valid_input = nil
until valid_input
puts " \\nPlease type in the \#{\"number\".colorize(:cyan)} of the previous fetch you would like to view\n or type \#{\"back\".colorize(:red)} to return to the main menu.\n USER_PROMPT\n \n #get the input fro mthe user\n user_selection = gets.chomp.downcase\n\n if user_selection == \"back\"\n system \"clear\"\n break\n end\n\n #convert my user input to an integer so that I can check to see if its in the valid range. \n user_integer = user_selection.to_i\n valid_input = valid_input_range.member?(user_integer)\n\n #If it is in the valid range, go and print out the selected WeatherConditions objects info again. Otherwise, keep asking for valid input and tell them how to go back. \n if valid_input \n selected_wc_obj = WeatherPup::WeatherConditions.all[user_integer - 1]\n type = selected_wc_obj.current_conditions_means\n\n case type \n when \"Zip Code\"\n system \"clear\"\n selected_wc_obj.print_zip_conditions\n self.return_to_main_menu_prompt\n system \"clear\"\n break\n when \"GPS Coordinates\"\n system \"clear\"\n selected_wc_obj.print_gps_conditions\n self.return_to_main_menu_prompt\n system \"clear\"\n break\n end\n else\n puts \"\\n\#{\"Invalid selection.\".colorize(:light_red)} Please try again or type \#{\"back\".colorize(:red)} to return to the main menu.\"\n end\n end\n end\nend\n"
|