Created
December 2, 2008 17:49
-
-
Save texel/31195 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
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