Sha256: 18941be7c7c551ca2a3c59842aaa3fa136addbd858b4ba2ac2b41465357dc058

Contents?: true

Size: 663 Bytes

Versions: 8

Compression:

Stored size: 663 Bytes

Contents

module Imb

  # @!group Internal

  # Maps codewords to characters.

  class CodewordMap

    # Constructor

    def initialize
      @characters = load_characters
    end

    # Given an array of codewords, ruturn their characters.
    # @param [[Integer]] codewords
    # @return [[Integer]] Array of 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

8 entries across 7 versions & 2 rubygems

Version Path
usps_intelligent_barcode-0.3.1 lib/usps_intelligent_barcode/codeword_map.rb
USPS-intelligent-barcode-0.2.7 lib/USPS-intelligent-barcode/codeword_map.rb
USPS-intelligent-barcode-0.2.6 lib/USPS-intelligent-barcode/codeword_map.rb
usps_intelligent_barcode-0.3.0 lib/USPS-intelligent-barcode/codeword_map.rb
usps_intelligent_barcode-0.3.0 lib/usps_intelligent_barcode/codeword_map.rb
USPS-intelligent-barcode-0.2.5 lib/USPS-intelligent-barcode/codeword_map.rb
USPS-intelligent-barcode-0.2.4 lib/USPS-intelligent-barcode/codeword_map.rb
USPS-intelligent-barcode-0.2.3 lib/USPS-intelligent-barcode/CodewordMap.rb