Class: Fixnum

Inherits:
Object show all
Defined in:
lib/more_ruby/fixnum.rb

Instance Method Summary collapse

Instance Method Details

#num_to_letterObject

Converts the number (1 <= x <= 26) to a letter 1 => A, 9 => I, 0 has no corresponding letter



6
7
8
9
# File 'lib/more_ruby/fixnum.rb', line 6

def num_to_letter
    raise "Do not call num_to_letter with a number that is not between 1 and 26" unless self >= 1 && self <= 26
    (self.to_i + 64).chr
end