Skip to content

Instantly share code, notes, and snippets.

@texel
Created December 2, 2008 17:49
Show Gist options
  • Save texel/31195 to your computer and use it in GitHub Desktop.
Save texel/31195 to your computer and use it in GitHub Desktop.
class Track
ATTRIBUTES = [:name, :id, :artist, :time, :rating]
ATTRIBUTES.each do |a|
attr_accessor a
end
def initialize(hash)
ATTRIBUTES.each do |attr|
self.send("#{attr}=", (hash[attr] || ""))
end
end
end
track = Track.new({:name => 'Do You Really Want to Hurt Me?', :artist => "Boy George", :time => '1982', :id => "YOUR FUCKING MOM"})
puts track.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment