Hi,

Am Samstag, 14. Jul 2007, 05:20:46 +0900 schrieb Mike Moore:
> Hey friends!  What is the best way to convert a Numeric to a string encoded
> with base 26?  I want the string to contain just alpha characters, not
> alphanumeric characters.  For now I'm using
>
>   num.to_s(26).tr('0-9a-p', 'a-z')
>
> and I'm wondering if there is a more concise way.

Isn't that concise enough? It's one line, it's
comprehensible right away and it reflects higher logic.
So what do you want more?

Compare it to this:

  class Fixnum
    def to_a_z
      n, r = abs, ""
      begin
        n, d = n.divmod 26
        r.insert 0, (d+?a).chr
      end while n > 0
      r.insert 0, "-" if self < 0
      r
    end
  end


Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de