YAMLの読み書き
ファイルから読み込み http://d.hatena.ne.jp/shokai/20090418/1240087782
書き出し
#!/usr/bin/env ruby require 'rubygems' require 'yaml' hash = Hash.new hash["x"] = 180 hash["y"] = 120 hash["name"] = "testtest" puts hash.to_yaml arr = Array.new arr[0] = hash hash2 = Hash.new hash2["year"] = 2009 hash2["month"] = "Oct" hash2["day"] = 15 arr[1] = hash2 puts arr.to_yaml
結果
--- name: testtest x: 180 y: 120 --- - name: testtest x: 180 y: 120 - month: Oct day: 15 year: 2009