Skip to content

Commit

Permalink
Add ruby-draw
Browse files Browse the repository at this point in the history
  • Loading branch information
santib committed Jan 14, 2025
1 parent eb4729e commit 5855a67
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions ruby-uy-draw.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
require "io/console"

def clear = system("clear")
def highlight(text) = "\e[1;32m#{text}\e[0m\n"
def blue(text) = "\e[1;34m#{text}\e[0m"

def draw(items)
shuffled_items = items.shuffle

clear
puts "Empezar el sorteo (enter para continuar):"
gets

60.times do |round|
highlight_index = round % items.size

style = -> (item, index) do
break highlight(item.upcase) if index == highlight_index
item
end

clear

puts "Eligiendo orden:"
puts

items
.map
.with_index { |item, index| puts " #{style.call(item, index)}"}

sleep(0.08)
end

clear

puts "Resultado final:"
puts

sleep(1)

shuffled_items.each_with_index do |item, index|
puts " #{index + 1}. #{blue(item)}"
sleep(0.5)
end

puts
end

sponsors = DATA.read.split("\n")

draw(sponsors)

__END__
rootstrap
neocoast
eagerworks
cedarcode
howdy
xmartlabs
effectussoftware
mimiquate
qubika
wyeworks

0 comments on commit 5855a67

Please sign in to comment.