Skip to content

Instantly share code, notes, and snippets.

@staybuzz
Created February 11, 2014 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save staybuzz/8934663 to your computer and use it in GitHub Desktop.
Save staybuzz/8934663 to your computer and use it in GitHub Desktop.
# タイマー
# とりあえず秒だけ
# メソッド作って、そこに秒数を引数として渡してあげちゃおう
def timer sec # 1秒おきにsecから値を引いていく
while sec > 0 do
sleep 1
sec -= 1
end
puts "時間です!"
end
begin
print "秒数を整数で指定してください: "
sec = gets.to_i
end until sec > 0 # 0以下の時再び入力させる
timer sec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment