Method: StudyTheMap::CLI#region

Defined in:
lib/study_the_map/cli.rb

#regionObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/study_the_map/cli.rb', line 75

def region

  region = nil
  while region != "back"

    puts "-----------------------------------------------------------------------"
    puts "1. Input a region for a list of ski resorts, or"
    puts '-----------------------------------------------------------------------'
    puts "2. Request a list of regions by typing the letter the region you're looking for starts with,"
    puts '-----------------------------------------------------------------------'
    puts "3. Or 'back' to return to the main menu."
    puts '-->'
    
    region = gets.strip
    
    if region.size == 1

      Region.starts_with(region)
      region

    else

      begin

        region_object = Region.new(region)
        region_object.full_list

      rescue Exception

        if region != "back"
          puts '-----------------------------------------------------------------------'
          puts "Not a valid region."
          puts '-----------------------------------------------------------------------'
        end

        region

      end      
    end
  end
end