Last active
December 12, 2018 12:41
-
-
Save ammaaim/b3b3511d49852f92b76c to your computer and use it in GitHub Desktop.
Read/Write YAML in Ruby
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
require 'yaml' | |
$db_file = 'filename.yaml' | |
def load_data | |
text = File.read 'db.yaml' | |
return YAML.load text | |
end | |
def store_data hash | |
f = File.open($db_file, 'w') | |
f.write hash.to_yaml | |
f.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment