Skip to content

Instantly share code, notes, and snippets.

/error.txt Secret

Created May 30, 2016 13:44
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 anonymous/79dee1aae800de3da00e2d98f972d18e to your computer and use it in GitHub Desktop.
Save anonymous/79dee1aae800de3da00e2d98f972d18e to your computer and use it in GitHub Desktop.
What it the artist name ?:>1
What is the song name ?:>2
library.rb:32:in `add_song': undefined method `<<' for nil:NilClass (NoMethodError)
from library.rb:59:in `<main>'
module Menu
puts "Hello ! This is an amazing app for organizing your music ! This is a
cool library ! It allows you to do multiple tasks
What would you like to do ?
-- 1 add a music ?
-- 2 delete a music ?
-- 3 delete an album ?
"
end
module Promptable
def prompt(message = "What music would you like to add", symbol = ":>")
print message
print symbol
gets.chomp
end
end
class Library
attr_accessor :artist, :song
def initialize
@library = {}
end
def add_artist(artist)
@library[artist] = []
end
def add_song(song)
@library[artist] << song
end
def show
puts @library
end
end
class Artist
attr_accessor :name, :song
def initialize(artist)
@name = artist[:name]
@song = artist[:song]
end
def to_s
"#{name}, #{song}"
end
end
if __FILE__ == $PROGRAM_NAME
include Promptable
include Menu
my_library = Library.new
my_library.add_artist(Artist.new(:name => prompt("What it the artist name ?")))
my_library.add_song(Artist.new(:song => prompt("What is the song name ?")))
my_library.show
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment