1. Список говнокодов пользователя naker

    Всего: 1

  2. Ruby / Говнокод #5119

    −110

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 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 Декабря 2010

    Комментарии (24)