- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 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 строк :)
Автор ошибся, что назвал one, two итд раздельно, вместо того, чтобы в единый массив их запихать.
это как bublic_html и /usr/blin/perl