Skip to content

Instantly share code, notes, and snippets.

@mathias
Created May 23, 2012 15:59
Show Gist options
  • Save mathias/2776091 to your computer and use it in GitHub Desktop.
Save mathias/2776091 to your computer and use it in GitHub Desktop.
SassyTomato Timer (for pomodoros)
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