Created
March 29, 2013 19:10
-
-
Save dmgarland/5272911 to your computer and use it in GitHub Desktop.
Here are some ideas for how to achieve a working StudentDirectory using YAML
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
# Let's make @directory an array, rather than a String | |
@directory = [] | |
# Pull in existing people from a YAML file | |
@directory += YAML.load_documents(File.open('student_directory.yml')) | |
# Save people to a YAML file | |
File.open('student_directory.yml', 'a') { |f| | |
@directory.compact.each do |person| | |
f.write(person.to_yaml) | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment