Sha256: 1377a179b352c7080010e5820fd2f5a3a82f1328747012a4ac3c3cf1ed020593

Contents?: true

Size: 809 Bytes

Versions: 1

Compression:

Stored size: 809 Bytes

Contents

module Imb

  # @!group Internal

  # For a given barcode position, maps to the "character" index and
  # bit number used to drive either the ascender or descender of that
  # position.
  class CharacterPosition

    # Construct an instance.
    #
    # @param character_index [Integer] The character's index within an
    #   array of characters.
    # @param bit_number [Integer] The character's bit number 
    def initialize(character_index, bit_number)
      @character_index = character_index
      @bit_number = bit_number
    end

    # Given an array of characters, return the bit for this position.
    #
    # @param characters [Array<Integer>]
    # @return [Integer] bit (0 or 1)
    def extract_bit_from_characters(characters)
      characters[@character_index][@bit_number]
    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/character_position.rb