I have ruby code that is supposed to create number of different files with some text inside. Exactly one of the files will have different text inside and nobody is supposed to know what file it is (kind of like a random card draw in group of people). It works really nice in ruby like this:
foo = "sample_text_A"
bar = "sample_text_B"
randomizer = [foo]
def create_file(i, text)
File.open("file_name_#{i}.txt", "w") do |f|
f.write(text)
end
end
def randomize(count, text, randomizer)
i = 0
(count-1).times do
randomizer << text
end
(count-1).times do
i += 1
sample_text = randomizer.delete_at(rand(randomizer.length))
create_file(i, sample_text)
end
end
randomize(4, bar, randomizer)
However, I now need to distribute this to number of people and I don't want them to be forced to install anything. So I figured it would be better distributed as a batch file (as far as I know, everyone of them runs Win). I am new to programming, often stumbling even with Ruby, so I wanted to ask for assistance, if anyone would be so kind and wrote similar thing as a .bat
Aucun commentaire:
Enregistrer un commentaire