Sha256: bca3da9dc608d7f880171d757d8d02a749bf14f44b04ebb8df67385f2dd6f043

Contents?: true

Size: 916 Bytes

Versions: 7

Compression:

Stored size: 916 Bytes

Contents

module Imb

  # @!group Internal

  # Represents a symbol in the barcode.

  class BarSymbol

    # @param [Integer] ascender_bit (0..1)
    # @param [Integer] descender_bit (0..1)
    # @return [BarSymbol]

    def self.make(ascender_bit, descender_bit)
      case [ascender_bit, descender_bit]
      when [0, 0]
        TRACKER
      when [0, 1]
        DESCENDER
      when [1, 0]
        ASCENDER
      when [1, 1]
        FULL
      end
    end

    # @return [Integer] the code for this symbol
    attr_reader :code

    # @return [String] the letter for this symbol
    attr_reader :letter

    # @param [Integer] code (0..3)
    # @param [String] letter

    def initialize(code, letter)
      @code = code
      @letter = letter
    end

    private

    TRACKER = BarSymbol.new(0, 'T')
    DESCENDER = BarSymbol.new(1, 'D')
    ASCENDER = BarSymbol.new(2, 'A')
    FULL = BarSymbol.new(3, 'F')

  end

end

Version data entries

7 entries across 6 versions & 2 rubygems

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