#!usr/bin/env ruby # -*- coding: utf-8 -*- date = [] hash = [] today = 1 puts "日記" while true choice = gets.chomp if choice == "1" year = Time.now.year mon = Time.now.mon day = Time.now.day data = "#{year}_#{mon}_#{day}" for i in 0..(date.length - 1) do if date[i].include?(data) puts "今日の日記はもう書き終わっています。" today = 2 break end end if today == 2 redo end puts "入力してください。" naiyou = gets.chomp puts "次に、今日の満足度を入力してください。" while true manzoku = gets.chomp if manzoku.to_i < 30 puts "この日記は「その他」からのみ閲覧することができるようになります。\nよろしいですか?" while true question = gets.chomp if question == "yes" break elsif question == "no" puts "もう一度入力してください。" redo else puts "もう一度入力してください。" redo end end break else redo end end date << data printf("%d年 %d月 %d日\n%s\n",year,mon,day,naiyou) redo elsif choice == "2" p hozon redo elsif choice == "3" break else redo end end