「rubyの入門」rubyでyamlファイルの読み書きサンプル

rubyコード:
require 'yaml’

hash = {1 => 'sqlite3’, 2 => 'postgresql’, 3 => 'mssql’, 4 => 'mysql’, 5 => 'oracle’}

# write yaml file
File.open(“/home/user007/data_startnews24.yaml", “wb") {|f| YAML.dump(hash, f) }

# read yaml file
data = YAML.load_file(“/home/user007/data_startnews24.yaml", “rb")

Ruby

Posted by arkgame