#!/usr/koeki/bin/ruby #-*- coding: utf-8 -*- require 'date' require 'yaml/store' datafile = "data.yaml" STDERR.print "今食べた品目は何種類?" n = gets.to_i if n == 0 then printf("食べてないんですね!\n") exit else printf("たべたものを入力してください。\n") end db = YAML::Store.new(datafile) db.transaction do e = db["食べたもの"] = db.fetch("食べたもの", Array.new) e << Date.today while 0 <= n-1 food = gets.chomp!.to_s e << food n -= 1 end puts e end