Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Forked from ammaaim/yaml.rb
Created December 12, 2018 12:41
Show Gist options
  • Save lbvf50mobile/64ac45c118cae770285362efd387b86f to your computer and use it in GitHub Desktop.
Save lbvf50mobile/64ac45c118cae770285362efd387b86f to your computer and use it in GitHub Desktop.
Read/Write YAML in Ruby
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