(改)アップデートを数えるプログラム(少し改良したつもりです)

前回のプログラムがあまりお粗末なので、少し直しました。

count10.rbの内容です。(TABキーでインデントしていますが、表示されないようです。)

file = gets()
if file == nil then
filename = ""
else
filename = file.chomp
end
if filename == "" then
p "File is empty..."
else
io = open(filename)
while io.closed? != true do
i = 0
j = 0
k = 0
string = io.gets
while string != nil do
character = string.slice(0..0)
if character == 'U' then
i += 1
end
if character == 'A' then
j += 1
end
if character == 'D' then
k += 1
end
string = io.gets
end
io.close
filedate = filename.slice(10..17)
result01 = sprintf(" UPDATE = %5d", i - 2)
result02 = sprintf(" ADD = %5d", j)
result03 = sprintf(" DELETE = %5d", k)
print filedate," ", result01, result02, result03,"\n"
nextfile = gets()
if nextfile != nil then
filename = nextfile.chomp
io = open(filename)
end
end
end

data01の内容です。

実行結果です。

manでsvn updateを調べたところ、正確には
UPDATEはUpdated
ADDはAdded
DELETEはDeletedだそうです。あしからず。