class LoopermanSamples::CLI

Public Instance Methods

call() click to toggle source
# File lib/looperman_samples/cli.rb, line 14
def call
  scrape
  main_menu
  play
  goodbye
end
goodbye() click to toggle source
# File lib/looperman_samples/cli.rb, line 73
def goodbye
  puts "see you tomorrow for more samples!"
end
main_menu() click to toggle source
play() click to toggle source

controls the play sequence

# File lib/looperman_samples/cli.rb, line 46
def play
  input = nil
    loop do
      puts "please enter the number of the sample you'd like to listen to or type exit:"
      input = gets.strip
      if input.to_i < @@sample_list.size + 1 && input.to_i > 0 #checks that input is greater than zero and less than list size
        sample = @@sample_list[input.to_i - 1] #takes user input, and sets sample variable using index lookup
        puts "You're listening to #{sample.title} by #{sample.creator.name}"
        puts "would you like to hear more from #{sample.creator.name}? (type yes or no)"
          input = gets.strip
          if input == "yes"
            puts "More by #{sample.creator.name}"
            @@sample_list = find_all_by_creator(sample)
            list_all_samples_by_creator(@@sample_list)
          elsif input == "no"
            main_menu
          end
      elsif input.to_i > LoopermanSamples::Sample.all.size
        puts "please enter a lower number"
      elsif input == "back"
        main_menu
      else
        break
      end
   end
end