Created
October 15, 2013 16:36
-
-
Save rosiehoyem/6994540 to your computer and use it in GitHub Desktop.
Serialize To Do
This file contains hidden or 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 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