Created
June 10, 2013 23:31
-
-
Save chhhris/5753393 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library { | |
:artist => { | |
"The Magnetic Fields" => { | |
"69 Love Songs" => ["Song 1", "Song 2"] | |
] | |
"Get Lost" => ["Song 1", "Song 2"] | |
} | |
"Netural Milk Hotel" => { | |
"In An Aeroplane Over the Sea" => ["Song 1", "Song 2"] | |
} | |
} | |
} | |
organized_library = Hash.new | |
songs.each do |song| | |
song_array = song.split("-") | |
artist = song_array[0].strip | |
album = song_array[1].strip | |
track = song_array[2].strip | |
organized_library[artist.to_sym] ||={} | |
organized_library[artist.to_sym] ||={album.to_sym} ||={} | |
organized_library[artist.to_sym] ||={album.to_sym} << track | |
# if organized_library[artist.to_sym] # weve seen this artist before | |
# if organized_library[artist.to_sym][album.to_sym] # weve seen this album before | |
# organized_library[artist.to_sym][album.to_sym] << track | |
# else | |
# organized_library[artist.to_sym][album.to_sym] = [track] | |
# end | |
# else | |
# organized_library[artist.to_sym] = {album.to_sym => [track]} | |
# end | |
end | |
puts organized_library.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment