-
-
Save lbvf50mobile/64ac45c118cae770285362efd387b86f to your computer and use it in GitHub Desktop.
Read/Write YAML in Ruby
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
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