class SeatSelector::AlphaConverter
Public Class Methods
to_i(alpha_str)
click to toggle source
A -> 1; C -> 3; AA -> 27; AAA -> 703
# File lib/seat_selector/alpha_converter.rb, line 4 def self.to_i(alpha_str) alpha_str.each_char.inject(0) do |sum, c| (sum * 26) + self.letter_values[c.downcase] end end
Private Class Methods
letter_values()
click to toggle source
# File lib/seat_selector/alpha_converter.rb, line 10 def self.letter_values @@letter_values ||= begin ("a".."z").each_with_object({}).with_index do |(chr, value_map), i| value_map[chr] = i + 1 end end end