Skip to content

Instantly share code, notes, and snippets.

@burtlo
Created September 5, 2012 22:31
Show Gist options
  • Save burtlo/3646485 to your computer and use it in GitHub Desktop.
Save burtlo/3646485 to your computer and use it in GitHub Desktop.
Working with YAML
name: 'La Crosse, WI'
code: LSE
directions: http://g.co/maps/62ufz
image: 'lacrosse-image.jpg'
website: http://www.cityoflacrosse.org/index.aspx?NID=851
rental_cars: http://www.cityoflacrosse.org/index.aspx?NID=882
description: La Crosse is the closest flight destination. It is right
on the Mississippi and about an hour away. It is a small airport so we
<strong>definitely recommend</strong> making a rental car reservation ahead of time.
require 'yaml'
yaml_data = YAML.load_file "data.yml"
# puts yaml_data["description"]
#
puts yaml_data.to_yaml
File.open("new_data.yml","w") do |file|
file.puts yaml_data.to_yaml
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment