class AtxLiveMusic::CLI

Public Instance Methods

another_date?() click to toggle source
# File lib/atx_live_music/cli.rb, line 52
def another_date?
  puts "\nWant to check out another date's listings? [Y or N]"
  
  input = gets.strip.upcase
  
  case input 
  when "Y"
    list_dates
    cta
  when "N"
    exit
  else
    puts "Huh?\n"
    another_date?
  end
end
call() click to toggle source
# File lib/atx_live_music/cli.rb, line 3
def call
  puts "Please wait while the roadies load in the shows...\n"    
  get_latest_shows
  list_dates
  cta    
end
cta() click to toggle source
# File lib/atx_live_music/cli.rb, line 26
def cta
  puts "\nSelect the date you want to rock on: [1 - 7 or 'exit']\n\n"    
  input = gets.strip
  input_num = input.to_i

  if input_num > 0 && input_num <= AtxLiveMusic::Dates.all.count
    input_num == 1 ? (puts "\nToday\n#{divider}") : (puts "\n#{AtxLiveMusic::Dates.all[input_num-1].string_date}\n#{divider}")
    display_shows_on_given_date(AtxLiveMusic::Dates.all[input_num-1])
    another_date?
  elsif input == "exit"
    exit
  elsif input_num == 0 || input_num > AtxLiveMusic::Dates.all.count
    puts "Which date did you want?"
    cta
  end

end
display_shows_on_given_date(date) click to toggle source
# File lib/atx_live_music/cli.rb, line 44
def display_shows_on_given_date(date)
  date.shows.each do |show|
    puts "SHOW: #{show.performance}"
    puts "VENUE: #{show.venue}"
    puts "LOCATION: #{show.location}\n\n"    
  end
end
divider() click to toggle source
# File lib/atx_live_music/cli.rb, line 69
def divider
  "=========================="
end
exit() click to toggle source
# File lib/atx_live_music/cli.rb, line 73
def exit
  puts "\nEnjoy the music! And remember...Keep Austin Weird."
  puts "**************************************************\n\n"
end
get_latest_shows() click to toggle source
# File lib/atx_live_music/cli.rb, line 10
def get_latest_shows
  AtxLiveMusic::Dates.get_seven_days
  
  AtxLiveMusic::Dates.all.each do |date|
    AtxLiveMusic::Shows.create_shows(date)      
  end
end
list_dates() click to toggle source
# File lib/atx_live_music/cli.rb, line 18
def list_dates
  puts "\n***** ATX Live Music *****\n\n"

  AtxLiveMusic::Dates.all.each_with_index do |date, index|
    index == 0 ? (puts "#{index+1}. Today") : (puts "#{index+1}. #{date.string_date}")      
  end
end