Skip to content

Instantly share code, notes, and snippets.

@adamjonas
Created October 15, 2012 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamjonas/3892467 to your computer and use it in GitHub Desktop.
Save adamjonas/3892467 to your computer and use it in GitHub Desktop.
Jukebox
puts "What do you want me to do? (Remember to type 'help' if you need it!)"
prompt = '> '
print prompt
input = gets.chomp.downcase.strip
puts "Sure... no problem"
# songs = [
# "The Magnetic Fields - 69 Love Songs - Parades Go By",
# "The Magnetic Fields - Get Lost - Smoke and Mirrors",
# "The Magnetic Fields - Get Lost - You, Me, and the Moon",
# "The Magnetic Fields - 69 Love Songs - The Book of Love",
# "Neutral Milk Hotel - In An Aeroplane Over the Sea - Holland 1945",
# "Neutral Milk Hotel - In An Aeroplane Over the Sea - The King of Carrot Flowers"
# ]
# artist = []
# album = []
# tracks = []
# songs.each do |song|
# piece = song.split(" - ")
# artist << piece[0]
# album << piece[1]
# tracks << piece[2]
# end
# artist = artist.uniq.sort
# album = album.uniq.sort
# tracks = tracks.uniq.sort
# puts "These are the artists: #{artist}"
# puts "These are the albums: #{album}"
# puts "These are the songs: #{tracks}"
def songs
{
"one"=>"The Phoenix - 1901",
"two"=>"Tokyo Police Club - Wait Up",
"three"=>"Sufjan Stevens - Too Much",
"four"=>"The Naked and the Famous - Young Blood",
"five"=>"(Far From) Home - Tiga",
"six"=>"The Cults - Abducted",
"seven"=>"The Phoenix - Consolation Prizes"
}
end
def list
puts "Listing all the songs...."
puts "#{songs}"
end
def play
puts "What number song do you want me to play?"
puts "You are going to have to type it out like 'one,' 'two,' etc..."
track = gets.chomp
case
when track == "one" || track == "The Phoenix - 1901"
puts "Playing... The Phoenix - 1901"
when track == "two" || track == "Tokyo Police Club - Wait Up"
puts "Playing Tokyo Police Club - Wait Up"
when track == "three" || track == "Sufjan Stevens - Too Much"
puts "Playing Sufjan Stevens - Too Much"
when track == "four" || track == "The Naked and the Famous - Young Blood"
puts "Playing The Naked and the Famous - Young Blood"
when track == "five" || track == "(Far From) Home - Tiga"
puts "playing (Far From) Home - Tiga"
when track == "six" || track == "The Cults - Abducted"
puts "playing The Cults - Abducted"
when track == "seven" || track == "The Phoenix - Consolation Prizes"
puts "playing The Phoenix - Consolation Prizes"
else
puts "that doesn't exist"
end
end
def help
puts "I can list things. Type 'list.'"
puts "I can play things. Tell me to 'play (the number of the song).'"
puts "If you type 'help,' I will tell you what I can do."
puts "If you want to leave type 'exit'"
end
if input == "list"
list
elsif input == "play"
play
elsif input == "exit"
exit
elsif input == "help"
help
puts "So, what do you want me to do?"
prompt = '> '
print prompt
second_input = gets.chomp
if second_input == "list"
list
elsif second_input == "play"
play
elsif second_input == "exit"
exit
elsif second_input == "help"
help
end
else puts "You are going to have to re-run the program you dope."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment