Skip to content

Instantly share code, notes, and snippets.

@rogerleite
Created April 3, 2009 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogerleite/89864 to your computer and use it in GitHub Desktop.
Save rogerleite/89864 to your computer and use it in GitHub Desktop.
@business_words = ['Sinergia','Mentalidade','Agregar','Mercado','E-mail','Follow up','Clientes','Benefício','Parceiros','Estratégia','Sistema','Rendimento','Pró-ativo','Business','Custos','Otimização','Foco','Efetivamente','A nível de','Recursos','Resultados','Paradigma','Projeto','Implementação','Integrar']
#puts @business_words
#puts '=========================================='
def generate_card number_words, number_columns
random_words = random_business_words number_words
card = []
number_lines = (number_words / number_columns)
number_lines.times do |line_index|
words = random_words.pop(number_columns)
card[line_index] = words
end
card
end
def random_business_words number_words
random_words = Array.new
while random_words.size < number_words do
randomIndex = rand @business_words.size
rword = @business_words[randomIndex].to_s
if !random_words.include? rword then
random_words.push rword
end
end
random_words
end
def print_card card
#get the size of the card's big word
size_to_center = -1
card.each do |line|
line.each do |word|
size_to_center = word.size if word.size > size_to_center
##puts "#{word.size} = #{word}"
end
end
#puts "#{size_to_center}"
columns = '<table border="1" width="400px">'
card.each do |line|
#column = '|' + line.pop.to_s.ljust(size_to_center) + '|'
columns += "<tr>"
line.each do |word|
columns += "<td>#{word}</td>"
end
columns += "</tr>"
end
columns += "</table>"
columns
end
tr_templates = []
5.times do |time|
card = generate_card 16, 4
tr_templates << print_card(card)
end
template_html = <<EOF
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
</head>
<body>
EOF
tr_templates.each { |tr| template_html += "<br>" + tr }
template_html += <<EOF
</body>
</html>
EOF
puts template_html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment