- 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 строк :)
naker 30.12.2010 22:15 # −2
guest 30.12.2010 22:41 # 0
naker 30.12.2010 22:50 # −1
guest 01.01.2011 10:07 # −7
istem 31.12.2010 01:59 # +8
naker 31.12.2010 03:11 # −2
Kevin 06.02.2011 06:06 # +1
Kevin 06.02.2011 06:23 # 0
Kevin 06.02.2011 06:49 # 0
naker 31.12.2010 03:24 # −2
istem 31.12.2010 09:22 # +5
guest 31.12.2010 18:18 # +5
guest 31.12.2010 18:18 # 0
KirAmp 31.12.2010 22:31 # +4
TarasB 31.12.2010 16:45 # +4
Автор ошибся, что назвал one, two итд раздельно, вместо того, чтобы в единый массив их запихать.
naker 31.12.2010 16:51 # −1
xXx_totalwar 31.12.2010 17:09 # −1
naker 31.12.2010 17:46 # −1
xXx_totalwar 31.12.2010 18:06 # −1
guest 01.01.2011 16:58 # 0
guest 01.01.2011 22:41 # 0
anmiles 03.01.2011 16:00 # −2
это как bublic_html и /usr/blin/perl
codesnik 07.01.2011 22:30 # +1
codesnik 08.01.2011 11:07 # +4