Skip to content

Instantly share code, notes, and snippets.

@rosiehoyem
Created October 15, 2013 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rosiehoyem/6994540 to your computer and use it in GitHub Desktop.
Save rosiehoyem/6994540 to your computer and use it in GitHub Desktop.
Serialize To Do
class Song
attr_accessor :title, :artist
def initialize
@artist = artist
end
def serialize
filename = self.title.downcase.gsub(' ','_')
text_to_write = "#{self.artist.name} - #{self.title}"
File.open("#{filename}.txt", 'w') { |file| file.write(text_to_write) }
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