Shoes.app { @width = 40 @left = 10 @margin = 10 @top = 180 @offset = @width + @margin @fill = red @hours1 = stack { fill @fill 2.times do |i| rect :left => @left, :top => (@top - (i*@offset)), :width => @width end } @left += @offset @hours2 = stack { fill @fill 4.times do |i| rect :left => @left, :top => (@top - (i*@offset)), :width => @width end } @left += @offset @minutes1 = stack { fill @fill 3.times do |i| rect :left => @left, :top => (@top - (i*@offset)), :width => @width end } @left += @offset @minutes2 = stack { fill @fill 4.times do |i| rect :left => @left, :top => (@top - (i*@offset)), :width => @width end } @left += @offset @seconds1 = stack { fill @fill 3.times do |i| rect :left => @left, :top => (@top - (i*@offset)), :width => @width end } @left += @offset @seconds2 = stack { fill @fill 4.times do |i| rect :left => @left, :top => (@top - (i*@offset)), :width => @width end } def get_image_pos_to_turn_on(num) images = [] images = [0] if num == "1" images = [1] if num == "2" images = [0,1] if num == "3" images = [2] if num == "4" images = [0,2] if num == "5" images = [1,2] if num == "6" images = [0,1,2] if num == "7" images = [3] if num == "8" images = [0,3] if num == "9" return images end def turn_on_images(stack, image_pos_array) stack.contents.each do |item| item.style :fill => @fill end image_pos_array.each do |pos| stack.contents[pos].style :fill => green end end every(1) do now = Time.new sec = now.sec.to_s.split(//) sec1 = [] sec1 = get_image_pos_to_turn_on(sec[0]) if sec.length > 1 sec2 = get_image_pos_to_turn_on(sec[sec.length-1]) turn_on_images(@seconds1, sec1) turn_on_images(@seconds2, sec2) min = now.min.to_s.split(//) min1 = [] min1 = get_image_pos_to_turn_on(min[0]) if min.length > 1 min2 = get_image_pos_to_turn_on(min[min.length-1]) turn_on_images(@minutes1, min1) turn_on_images(@minutes2, min2) hrs = now.hour.to_s.split(//) hrs1 = [] hrs1 = get_image_pos_to_turn_on(hrs[0]) if hrs.length > 1 hrs2 = get_image_pos_to_turn_on(hrs[hrs.length-1]) turn_on_images(@hours1, hrs1) turn_on_images(@hours2, hrs2) end }