music

 On 2012-09-16 and filed under: offtopic


A bit of Ruby to start things off (I guess I should say ‘test’ in here too).

#!/usr/bin/env ruby

class Music
  attr_accessor :id, :artist, :title, :album
end

songs = Array.new

ARGV.each do |m|
  f = File.open(m)
  while (l = f.gets)
    info = l.split(';')

    if info.length > 0
      song = Music.new
      song.id = info[0]
      song.title = info[1]
      song.artist = info[2]
      song.album = info[3]
      songs << song
    end
  end
  f.close()
end

songs.each do |s|
  puts "#{s.artist} - #{s.title} - #{s.album}"
end

eh?