Sha256: 2b416be190b64ba81dcfaa92e17b116653ce9bb3191eaa6c0e4a2c1286f4f42e

Contents?: true

Size: 855 Bytes

Versions: 3

Compression:

Stored size: 855 Bytes

Contents

# CLI Controller
class BestHikingTrails::CLI

  def call
    list_trails
    trail_info
  end

  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

  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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
best-hiking-trails-0.1.2 lib/best_hiking_trails/cli.rb
best-hiking-trails-0.1.1 lib/best_hiking_trails/cli.rb
best-hiking-trails-0.1.0 lib/best_hiking_trails/cli.rb