Class: StudyTheMap::CLI
- Inherits:
-
Object
- Object
- StudyTheMap::CLI
- Defined in:
- lib/study_the_map/cli.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/study_the_map/cli.rb', line 5 def call get_areas goodbye end |
#get_areas ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/study_the_map/cli.rb', line 40 def get_areas input = nil while input != 'exit' puts "1. Select a region (type 'region') or Ski Resort (type 'resort') to study associated ski trail maps!" puts '-----------------------------------------------------------------------' puts "2. Or check out the world map to find resorts and trails: (type 'world')" puts '-----------------------------------------------------------------------' puts "3. Enter the area you would like to search:" puts '-->' input = gets.strip.downcase case input when "region" region when "world" Launchy.open("http://openskimap.org/") when "resort" get_map else puts "Please enter 'region', 'resort', or 'world'" puts '-----------------------------------------------------------------------' end end end |
#get_map ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/study_the_map/cli.rb', line 13 def get_map resort_name = nil while resort_name != 'back' puts "1. Please enter the name of the ski area you would like the map for:" puts '-----------------------------------------------------------------------' puts "2. Or type 'back' to go back to the main menu." puts '-->' resort_name = gets.strip if resort_name == 'back' get_areas elsif Region.ski_area_list.include?(resort_name) SkiMaps.new(resort_name) else puts "Invalid ski area name" end end end |
#goodbye ⇒ Object
117 118 119 120 |
# File 'lib/study_the_map/cli.rb', line 117 def goodbye puts "Come back anytime for more maps!" end |
#region ⇒ Object
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 |