Skip to content

Instantly share code, notes, and snippets.

@plexus
Created February 26, 2014 11:11
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 plexus/9227711 to your computer and use it in GitHub Desktop.
Save plexus/9227711 to your computer and use it in GitHub Desktop.
# Tea timer
Shoes.app do
@time = 0
@backgrounds = []
@colors = {
white: '#ffffff',
green: '#00ff00',
red: '#ff0000',
}
stack do
@label = banner '0:00'
flow do
[2, 15, 30, 60].each do |i|
button i.to_s do
@time += i
end
end
end
end
every do
puts @time
if @time > 0
@time -= 1
@label.text = "%d:%02d" % [@time/60, @time%60]
if @time == 0
@backgrounds += [:white, :green, :red, :green, :red]
end
end
unless @backgrounds.empty?
background @colors[@backgrounds.pop]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment