From 5855a67a13bfaf9a0bb10fa4e2d8c6d7e561938a Mon Sep 17 00:00:00 2001 From: Santiago Bartesaghi Date: Tue, 14 Jan 2025 20:26:55 -0300 Subject: [PATCH] Add ruby-draw --- ruby-uy-draw.rb | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 ruby-uy-draw.rb diff --git a/ruby-uy-draw.rb b/ruby-uy-draw.rb new file mode 100644 index 0000000..9c787ca --- /dev/null +++ b/ruby-uy-draw.rb @@ -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