#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'csv'
CSV.open("sutokku.csv" , "w") do |yotei|
yotei << ["分類" , "数"]
end
puts "まずは最初のストック数を確認します"
print "ティッシュはいくつありますか:"
texi = gets.chomp.to_i
print "トイレットペーパーはいくつありますか:"
toire = gets.chomp.to_i
print "固形石鹸はいくつありますか:"
sekken = gets.chomp.to_i
print "鉛筆はいくつありますか:"
enpi = gets.chomp.to_i
print "ノートはいくつありますか:"
noto = gets.chomp.to_i
print "ラップはいくつありますか:"
rappu = gets.chomp.to_i
print "キッチンペーパーはいくつありますか:"
kittin = gets.chomp.to_i
print "ゴミ袋はいくつありますか:"
gomi = gets.chomp.to_i
print "除菌シートはいくつありますか:"
jokin = gets.chomp.to_i
print "シャンプーはいくつありますか:"
syan = gets.chomp.to_i
print "リンスはいくつありますか:"
rinsu = gets.chomp.to_i
print "綿棒はいくつありますか:"
menbo = gets.chomp.to_i
print "化粧水はいくつありますか:"
kesyo = gets.chomp.to_i
print "食器用洗剤はいくつありますか:"
senzai = gets.chomp.to_i
print "マスクはいくつありますか:"
masuku = gets.chomp.to_i
print "歯ブラシはいくつありますか:"
burasi = gets.chomp.to_i
print "ポケットティッシュはいくつありますか:"
poketexi= gets.chomp.to_i
CSV.open("sutokku.csv", "a") do |yotei|
yotei << ["ティッシュ" , texi]
yotei << ["トイレットペーパー" , toire]
yotei << ["固形石鹸" , sekken]
yotei << ["鉛筆" , enpi]
yotei << ["ノート" , noto]
yotei << ["ラップ" , rappu]
yotei << ["キッチンペーパー" , kittin]
yotei << ["ゴミ袋" , gomi]
yotei << ["除菌シート" , jokin]
yotei << ["シャンプー" , syan]
yotei << ["リンス" , rinsu]
yotei << ["綿棒" , menbo]
yotei << ["化粧水" , kesyo]
yotei << ["食器用洗剤" , senzai]
yotei << ["マスク" , masuku]
yotei << ["歯ブラシ" , burasi]
yotei << ["ポケットティッシュ" , poketexi]
end
puts "保存が完了しました。"
puts "管理を開始します。"
while true
print "ストック数が変わったものを入力してください。終了する場合は「break」と入力してください:"
heri = gets.chomp
if heri == "break"
print "次回の起動時にすべてのデータが消去されます。それでも終了しますか?する場合は1、しない場合は0を入力してください:"
yameru = gets.chomp.to_i
if yameru == 1
break
else
redo
end
else
data = CSV.read("sutokku.csv" ,headers: true)
data.each do |row|
if row[0] == heri
printf("%sは前回の時点では%sつストックがあります。\n", row[0] , row[1])
kawaru = row[0]
print "いくつになりましたか?:"
kazuha = gets.chomp.to_i
CSV.open("sutokku.csv" , "a") do |yotei|
yotei << [kawaru , kazuha]
end
else
puts "それはデータに入っていないようです"
end
end
end
end