Module: Schatter::Index

Constant Summary collapse

LETTERS =
%w{a b c d e f g h i j}

Instance Method Summary collapse

Instance Method Details

#from_index(string) ⇒ Object



8
9
10
# File 'lib/schatter/index.rb', line 8

def from_index string
  string.scan(/./).map{|c| LETTERS.index c}.join.to_i
end

#to_index(number) ⇒ Object



4
5
6
# File 'lib/schatter/index.rb', line 4

def to_index number
  number.to_s.scan(/./).map{|c| LETTERS[c.to_i]}.join('')
end