File tree Expand file tree Collapse file tree 1 file changed +63
-0
lines changed
Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ require "io/console"
2+
3+ def clear = system ( "clear" )
4+ def highlight ( text ) = "\e [1;32m#{ text } \e [0m\n "
5+ def blue ( text ) = "\e [1;34m#{ text } \e [0m"
6+
7+ def draw ( items )
8+ shuffled_items = items . shuffle
9+
10+ clear
11+ puts "Empezar el sorteo (enter para continuar):"
12+ gets
13+
14+ 60 . times do |round |
15+ highlight_index = round % items . size
16+
17+ style = -> ( item , index ) do
18+ break highlight ( item . upcase ) if index == highlight_index
19+ item
20+ end
21+
22+ clear
23+
24+ puts "Eligiendo orden:"
25+ puts
26+
27+ items
28+ . map
29+ . with_index { |item , index | puts " #{ style . call ( item , index ) } " }
30+
31+ sleep ( 0.08 )
32+ end
33+
34+ clear
35+
36+ puts "Resultado final:"
37+ puts
38+
39+ sleep ( 1 )
40+
41+ shuffled_items . each_with_index do |item , index |
42+ puts " #{ index + 1 } . #{ blue ( item ) } "
43+ sleep ( 0.5 )
44+ end
45+
46+ puts
47+ end
48+
49+ sponsors = DATA . read . split ( "\n " )
50+
51+ draw ( sponsors )
52+
53+ __END__
54+ rootstrap
55+ neocoast
56+ eagerworks
57+ cedarcode
58+ howdy
59+ xmartlabs
60+ effectussoftware
61+ mimiquate
62+ qubika
63+ wyeworks
You can’t perform that action at this time.
0 commit comments