class RQRCodeCore::QRAlphanumeric

def self.valid_data?(data)

def self.valid_data?(data)
  (data.chars - ALPHANUMERIC).empty?
end

def initialize(data)

def initialize(data)
  unless QRAlphanumeric.valid_data?(data)
    raise QRCodeArgumentError, "Not a alpha numeric uppercase string `#{data}`"
  end
  @data = data
end

def write(buffer)

def write(buffer)
  buffer.alphanumeric_encoding_start(@data.size)
  @data.size.times do |i|
    if i % 2 == 0
      if i == (@data.size - 1)
        value = ALPHANUMERIC.index(@data[i])
        buffer.put(value, 6)
      else
        value = (ALPHANUMERIC.index(@data[i]) * 45) + ALPHANUMERIC.index(@data[i + 1])
        buffer.put(value, 11)
      end
    end
  end
end