Sha256: 497034d1203922d9ea6df89d0f777bdabaf9ba229af37dc6dc2abf234ced46a5

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

class Blockers::CLI

  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

  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

  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

  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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blockers-cli-app-0.1.0 lib/blockers/cli.rb