Skip to content

Instantly share code, notes, and snippets.

@dmgarland
Created March 29, 2013 19:10
Show Gist options
  • Save dmgarland/5272911 to your computer and use it in GitHub Desktop.
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
# 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