|
Hey! Someone worked hard on
String::rjust()! Put it to good use! :)
---Michael B. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sergio Pinon Sent: January 23, 2006 2:57 PM To: [email protected] Subject: Re: [Wtr-general] Random number generation. I don’t know too much
about the first problem that you are having but as for your second one try this.
I changed the max to be no higher than 99999 and then you get a maximum of 5
digits. If you have less then I just concat zeros on the end. Hope this
helps. Sergio def
Random_number $rand_num
= rand(max=99999).to_s()
while
$rand_num.length < 5
$rand_num << "0"
end
puts ("tester"+ ($rand_num))
return
$rand_num end From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of
[EMAIL PROTECTED] I have 2
questions: Can I use method names other
then "test_sometest" in my script. For example, I have a method that performs a
calculation and returns a value and passes that value to test method. Unless I
rename my calculation method as "test_calculation" the method is not executed. I
know that my class is inheriting from test::unit, but do I need to precede every
method name with "test"? Secondly, I am trying to generate
test users for my test by generating a random number and the concatenating
that number to a string "test" so that the result is "test12345", for
example. I'm using rand(max-0) to generate
the number, but it returns a big number. So I tried stripping the number and
then concatenating but it didn't work. Ultimately, I would like to have generate
names with 5 digits randomly like the example above. Any
ideas? def
Random_name $rand_user =
$rand_num.to_s |
_______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
