class Blockers::CLI
Public Instance Methods
blocker_info(item)
click to toggle source
# File lib/blockers/cli.rb, line 19 def blocker_info(item) puts "\nšš šš šš šš šš" puts "\nYou chose the #{item.name.strip.chomp(".")}." puts "It's listed for #{item.price}." puts "Buy it here: \n#{item.url}" puts "\nšš šš šš šš šš" puts "\nTo regenerate the list, type 'list'.\nTo exit, type 'exit'." input = gets.strip.downcase while input != "exit" && input != "list" puts "š Invalid response; to return to the list, type 'list.'\nTo exit, type 'exit'." input = gets.strip.downcase end if input == "exit" puts "š So long. Keep blocking the pucks. š" elsif input == "list" Blockers::Blocker.delete commence end end
blocker_list()
click to toggle source
# File lib/blockers/cli.rb, line 12 def blocker_list puts "Here are the blockers (cheapest one first):\n\n" Blockers::Blocker.all.each_with_index do |blocker, i| puts "#{i + 1}. #{blocker.name}" end end
commence()
click to toggle source
# File lib/blockers/cli.rb, line 39 def commence Blockers::Blocker.scrape display blocker_list input = nil puts "\nš šµ š š šµ šµ šµ š š š š š š š š š š šµ šµ šµ š š šµ š" puts "\nEnter a blocker's number (1-20) for more info:" input = gets.strip.to_i while !input.between?(1, 20) puts "š Invalid response; please enter the number (1-20) for which you'd like to see more info: " input = gets.strip.to_i end index = input - 1 item = Blockers::Blocker.find(index) blocker_info(item) end
display()
click to toggle source
# File lib/blockers/cli.rb, line 3 def display monkeys = "šµ " * 15 sticks = "š " * 15 puts monkeys + "\n" * 2 puts "Finally a program for you, someone who wants to see the 20 cheapest senior-sized blockers at GoalieMonkey.com without necessarily looking at pictures of them." + "\n" * 2 puts sticks + "\n" * 2 end