Class: BestHikingTrails::CLI
- Inherits:
-
Object
- Object
- BestHikingTrails::CLI
- Defined in:
- lib/best_hiking_trails/cli.rb
Overview
CLI Controller
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
4 5 6 7 |
# File 'lib/best_hiking_trails/cli.rb', line 4 def call list_trails trail_info end |
#list_trails ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/best_hiking_trails/cli.rb', line 9 def list_trails puts "The top 10 hiking trails" @trails = BestHikingTrails::Trail.scrape @trails.each.with_index(1) do |trail, i| puts "#{trail.name}" end end |
#trail_info ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/best_hiking_trails/cli.rb', line 17 def trail_info input = nil while input != "exit" puts "Enter the number of the trail you would like more information on, Enter list to relist the trails, or type exit to exit the program." input = gets.strip if input.to_i > 0 && input.to_i <= 10 the_trail = @trails[input.to_i-1] puts "#{the_trail.name}, #{the_trail.information}" elsif input == "list" list_trails elsif input == "exit" puts "Have a nice day!" else puts "Unfortunately that is not an option." end end end |