1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | require 'time'
pomo = ARGV[0].to_i # 1 pomodoro durations
interval = ARGV[1].to_i # rest durations
long_rest = ARGV[2].to_i # long rest durations
one_set = pomo*4 + interval*3 + long_rest # min
puts one_set # min
tempotime_0 = Time.new
tempotime = Time.new
mission_finish_time = tempotime_0 + one_set*60 # sec
#puts tempotime_0
#puts mission_finish_time
#minutes = (mission_finish_time - tempotime_0).to_i.div(60)
#puts "#{minutes/60}:#{minutes%60}"
#exit
fh = mission_finish_time.hour.to_s
fm = mission_finish_time.min
if fm < 10
fm = "0" + fm.to_s
end
fs = mission_finish_time.sec
if fs < 10
fs = "0" + fs.to_s
end
count_i = 0
ii = 0
rest = false
pomodoro = 1
resttimes = interval
while count_i < one_set do
now = Time.new
if now > mission_finish_time
now = nil
break
end
now = nil
seconds = 0
if pomodoro < 4
if ii == pomo && rest == false # 25min work , 5min rest
rest = true
ii = 0
elsif rest == true && ii > interval - 1 # 5min rest
pomodoro += 1
ii = 0 # reset
rest = false
end
elsif pomodoro > 3
if ii == pomo
rest = true # 10min long rest
resttimes = long_rest
end
end
while seconds < 60 do
t = Time.new
if ((t - tempotime).to_i > 0)
system("clear")
puts t
puts tempotime
tempotime = t
seconds += 1
puts "end time #{fh}:#{fm}:#{fs}"
puts
puts "one_set:#{one_set}"
puts "count_i:#{count_i}"
puts "1 pomodoro = #{pomo} min, rest = #{interval} min"
puts "long rest = #{long_rest} min"
puts
puts " 1 pomodoro #{pomo} min -> rest #{interval} min -> 1 pomodoro #{pomo} min -> rest #{interval} min"
puts " 1 pomodoro #{pomo} min -> rest #{interval} min -> 1 pomodoro #{pomo} min -> long rest #{long_rest} min"
puts
puts "total #{one_set} min"
puts
if rest == true
puts "rest: #{pomodoro}"
else
puts "pomodoro: #{pomodoro}"
end
puts "total time: " + count_i.to_s + " min"
if rest == true
# puts "remain: #{(resttimes - ii)} min"
puts "remain: #{((tempotime_0 + pomo*60*pomodoro + resttimes*60*(pomodoro)) - t).to_i.div(60)} min #{(((tempotime_0 + pomo*60*pomodoro + resttimes*60*(pomodoro - 1)) - t).to_i).modulo(60)} sec"
else
# puts "remain: #{(pomo - ii)} min"
puts "remain: #{((tempotime_0 + pomo*60*pomodoro + resttimes*60*(pomodoro - 1)) - t).to_i.div(60)} min #{(((tempotime_0 + pomo*60*pomodoro + resttimes*60*(pomodoro - 1)) - t).to_i).modulo(60)} sec"
end
h = t.hour
m = t.min
s = t.sec
if m < 10
m = "0" + m.to_s
end
if s < 10
s = "0" + s.to_s
end
puts
puts("#{h}:#{m}:#{s}")
end
t = nil
end
ii += 1
count_i += 1
end
puts "4 pomodoro completed."
|