#!/usr/bin/env ruby
$KCODE = 'e'
require 'cgi'
require 'pstore'
ticket = PStore.new("ticket.db")
print("Content-type: text/html; charset=EUC-JP\n\n")
print("\n")
print("
\n")
print("本日の乗降客数\n")
print("\n")
print("\n")
sales = Hash.new
ticket.transaction do
for time in ticket.roots
sales[time] = ticket[time]
# Hash sales にデータを読みこませる
end
end
peak = Hash.new(0) # 到着駅名を key とし、value に人数をしまう
for time in sales.keys
stop = sales[time][1]
peak[stop] += 1
end
# p peak
print("本日の乗降客数
")
print("\n")
print("\n")
print("到着駅 | 人数 | ")
print("
\n")
for station in peak.keys
print("\n")
printf("%s | %s | \n", station, peak[station])
print("
\n")
end
print("
\n")
print("\n")
print("\n")