Sha256: 5c5297f65cf06834422ae078fade86ca665809186ab3585ac79c6909ef6e1a6d

Contents?: true

Size: 604 Bytes

Versions: 2

Compression:

Stored size: 604 Bytes

Contents

module Imb

  # Maps codewords to characters.  This class is internal and may
  # change.

  class CodewordMap

    # Constructor

    def initialize
      @characters = load_characters
    end

    # Given an array of codewords, ruturn their characters.

    def characters(codewords)
      codewords.map do |codeword|
        @characters[codeword]
      end
    end

    private

    def load_characters
      YAML.load_file(characters_path)
    end

    def characters_path
      File.expand_path('codeword_to_character_mapping.yml',
                       File.dirname(__FILE__))
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
USPS-intelligent-barcode-0.2.2 lib/USPS-intelligent-barcode/CodewordMap.rb
USPS-intelligent-barcode-0.2.1 lib/USPS-intelligent-barcode/CodewordMap.rb