Skip to content

Instantly share code, notes, and snippets.

@samueldowens
Created October 15, 2013 13:33
Show Gist options
  • Select an option

  • Save samueldowens/6991613 to your computer and use it in GitHub Desktop.

Select an option

Save samueldowens/6991613 to your computer and use it in GitHub Desktop.
Serialize Solution
class Song
attr_accessor :title, :artist
def serialize
File.new("#{self.title.gsub(" ", "_")}.txt", "w")
File.open("#{self.title.gsub(" ", "_")}.txt", "w") do |f|
f.print "#{self.artist.name} - #{self.title}"
end
end
end
class Artist
attr_accessor :name
def initialize(name)
@name = name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment