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