On Feb 8, 2012, at 08:36 , Bravo Man wrote:

> Hi,
>=20
> I come from the world of other programming languages and in the =
process
> of learning Ruby I am trying to implement a few algorithms.
>=20
> It would be great if you could assist me with proposal for =
implementing
> it in a more "ruby" way tham directly following the pattern from =
"java"
> for example.
>=20
> I would like to convert integers to strings where the strings are of =
the
> form XXX. X is a digit from 0 to 9 or a letter from A to Z. So 11 gets
> converted to 00B. 37 is 010. And 46656 gets converted to ZZZ.

I know you're trying to do some exercises to learn ruby so this =
suggestion is probably not entirely apropros, but I think your math =
might be bad (OR: I'm uncaffienated, OR: I missed something obvious).=20

>> 11.to_s 36
=3D> "b"
>> 37.to_s 36
=3D> "11"
>> 46656.to_s 36
=3D> "1000"
>> 46655.to_s 36
=3D> "zzz"

the rest of the formatting can easily be done using String methods:

>> 37.to_s(36).rjust(3,'0')
=3D> "011"

And I agree with Steve... the name is terrible. In this case I'd =
probably put a method on Fixnum and name it to_key or somesuch.

37.to_key # =3D> "011"