Created
May 23, 2012 15:59
-
-
Save mathias/2776091 to your computer and use it in GitHub Desktop.
SassyTomato Timer (for pomodoros)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shoes.app :height => 185, :width => 215, :title => "SassyTomato" do | |
background white | |
@time_to_start = Time.new | |
@stopped = true | |
flow do | |
stack :margin => 10, :width => 75 do | |
image "http://i.imgur.com/NgtbE.jpg" | |
end | |
stack :margin => 10, :width => -75 do | |
button "Pomodoro" do | |
@time_to_stop = Time.now + 25 * 60 | |
run | |
end | |
button "Short Break" do | |
@time_to_stop = Time.now + 5 * 60 | |
run | |
end | |
button "Long Break" do | |
@time_to_stop = Time.now + 15 * 60 | |
run | |
end | |
button "Stop" do | |
stop | |
end | |
end | |
flow :align => "center" do | |
@label = para "Press start." | |
end | |
end | |
def run | |
@stopped = false | |
every 1 do | |
return if @stopped | |
tick | |
if Time.now > @time_to_stop | |
stop | |
end | |
end | |
end | |
def stop | |
@stopped = true | |
@label.replace "Done!" | |
end | |
def tick | |
time_remaining = @time_to_stop - Time.now | |
minutes = (time_remaining / 60).floor | |
seconds = (time_remaining % 60).floor | |
@label.replace "#{minutes}:#{seconds} remaining." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment