class DansDeals::CLI

Public Instance Methods

call() click to toggle source
# File lib/dansdeals/cli.rb, line 2
def call
  @counter = 1    #@counter is needed so that the #list_deals method, which lists 5 deals at a time, should list the right 5.
  list_deals
  menu
  goodbye
end
goodbye() click to toggle source
# File lib/dansdeals/cli.rb, line 50
def goodbye
  puts "\nThanks for stopping by, see you soon!"
end
list_deals() click to toggle source
# File lib/dansdeals/cli.rb, line 9
def list_deals
  puts "\nTodays Deals:"
  deal = DansDeals::Deals.latest
  @list = deal[((@counter * 5) - 5)..(@counter * 5) -1].collect {|deal| deal}
  if @list.empty?
    puts "That's all the deals for today."
    @counter -= 1
  end
  @list.each.with_index(1) do |deal, i|
    puts "\n#{i}. #{deal.title}"
  end
end
menu() click to toggle source