print<!DOCTYPE html> #!/usr/bin/env ruby # coding: utf-8 require 'cgi' cgi = CGI.new(:accept_charset => "UTF-8") print "Content-type: text/html; charset=UTF-8\n\n" # フォームから送信された時間データを取得 timeValue = cgi['mg1'] # タイマーの値に応じてmoziを設定 mozi = if timeValue >= '00:00:000' && timeValue < '00:03:000' 'bad' elsif timeValue >= '00:03:000' && timeValue < '00:04:000' 'eary' elsif timeValue >= '00:04:000' && timeValue < '00:04:500' 'great' elsif timeValue >= '00:04:500' && timeValue <= '00:05:300' 'perfect' else 'not found' end # HTMLを出力 <html lang="ja">\n" print "<html>\n" print "<head>\n" print "<title>結果発表</title>\n" print "<meta http-equiv=\"Content-Style-Type\" content=\"text/css\">\n" print<form method="POST" action="./game.rb"> print "<style type=\"text/css\">\n" # CSSスタイルなど print "</style>\n" print "</head>\n" print "<body>\n" print "<h1>タイマー結果!!</h1>\n" print "<h2>経過時間: {timeValue}です。{mozi}。</h2>\n" print "</body>\n" print "</html>\n" end