Sha256: f217639df002f8539d5bf8e243e873f5a9e632e8a84e963cc64257e26fa7e3c6

Contents?: true

Size: 662 Bytes

Versions: 1

Compression:

Stored size: 662 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

1 entries across 1 versions & 1 rubygems

Version Path
usps_intelligent_barcode-1.0.0 lib/usps_intelligent_barcode/codeword_map.rb