- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
require "date"
#Конвертируем массив цифр в двухмерный масив для отображения
def get_numbers(numbers)
  output = []
  one = [["-","-","-","*","*"],["-","-","*","-","*"],["-","*","-","-","*"],["*","-","-","-","*"],["-","-","-","-","*"],["-","-","-","-","*"],["-","-","-","-","*"]]
  two = [["*","*","*","*","*"],["-","-","-","-","*"],["-","-","-","-","*"],["*","*","*","*","*"],["*","-","-","-","-"],["*","-","-","-","-"],["*","*","*","*","*"]]
  three = [["*","*","*","*","*"],["-","-","-","-","*"],["-","-","-","-","*"],["*","*","*","*","*"],["-","-","-","-","*"],["-","-","-","-","*"],["*","*","*","*","*"]]
  four = [["*","-","-","-","*"],["*","-","-","-","*"],["*","-","-","-","*"],["*","*","*","*","*"],["-","-","-","-","*"],["-","-","-","-","*"],["-","-","-","-","*"]]
  five = [["*","*","*","*","*"],["*","-","-","-","-"],["*","-","-","-","-"],["*","*","*","*","*"],["-","-","-","-","*"],["-","-","-","-","*"],["*","*","*","*","*"]]
  six = [["*","*","*","*","*"],["*","-","-","-","-"],["*","-","-","-","-"],["*","*","*","*","*"],["*","-","-","-","*"],["*","-","-","-","*"],["*","*","*","*","*"]]
  seven = [["*","*","*","*","*"],["-","-","-","-","*"],["-","-","-","*","-"],["-","-","*","-","-"],["-","*","-","-","-"],["*","-","-","-","-"],["*","-","-","-","-"]]
  eight = [["*","*","*","*","*"],["*","-","-","-","*"],["*","-","-","-","*"],["*","*","*","*","*"],["*","-","-","-","*"],["*","-","-","-","*"],["*","*","*","*","*"]]
  nine = [["*","*","*","*","*"],["*","-","-","-","*"],["*","-","-","-","*"],["*","*","*","*","*"],["-","-","-","-","*"],["-","-","-","-","*"],["*","*","*","*","*"]]
  zero = [["*","*","*","*","*"],["*","-","-","-","*"],["*","-","-","-","*"],["*","-","-","-","*"],["*","-","-","-","*"],["*","-","-","-","*"],["*","*","*","*","*"]]
  seperator = [["-","-","-","-","-"],["-","*","-","*","-"],["-","-","-","-","-"],["-","-","-","-","-"],["-","-","-","-","-"],["-","*","-","*","-"],["-","-","-","-","-"]]
  for i in numbers
    case i
      when "0"
        output += [zero]
      when "1"
        output += [one]
      when "2"
        output += [two]
      when "3"
        output += [three]
      when "4"
        output += [four]
      when "5"
        output += [five]
      when "6"
        output += [six]
      when "7"
        output += [seven]
      when "8"
        output += [eight]
      when "9"
        output += [nine]
      when ":"
        output += [seperator]
    end
  end  
  return output
end
#Получаем массив с текущим временем
def get_time
  t = Time.new
  if t.hour.between?(0,9)
    hour = "0" + t.hour.to_s
  else
    hour = t.hour.to_s
  end
  if t.min.between?(0,9)
    min = "0" + t.min.to_s
  else
    min = t.min.to_s
  end
  if t.sec.between?(0,9)
    sec = "0" + t.sec.to_s
  else
    sec = t.sec.to_s
  end
  time = [hour[0],hour[1],":",min[0],min[1],":",sec[0],sec[1]]
end
#Рисуем с заменой символов на в
def display_time(symbols = {:star => "0", :line => " "})
  color_taf = 0
  color_tab = 7
  loop do
	#Для очитки экрана в UNIX
	if RUBY_PLATFORM == "i386-mingw32" then
	  system("cls")
	else
	  system("tput reset")
	end
	#Цвет и фон
    #system("tput setaf #{color_taf}")
    #system("tput setab #{color_tab}")
    m = get_numbers(get_time)
    #Посимвольная прорисовка
    for j in 0..6
      for i in 0..m.size-1
        for z in m[i][j]
          case z
            when "*"
              print symbols[:star]
            when "-"
              print symbols[:line]
            #sleep(0.01) Для просмотра прорисовки
          end
        end
        print " "
      end
      print "\n"
    end
    sleep(1)
  end
end
#Рисуем
display_time :star => "0", :line => " "
                                     
        
            Фух... урезал до 100 строк :)