Class: Imb::BarSymbol

Inherits:
Object
  • Object
show all
Defined in:
lib/USPS-intelligent-barcode/bar_symbol.rb

Overview

Represents a symbol in the barcode.

Internal collapse

Internal collapse

Constructor Details

#initialize(code, letter) ⇒ BarSymbol

Returns a new instance of BarSymbol.

Parameters:

  • code (Integer)

    (0..3)

  • letter (String)


35
36
37
38
# File 'lib/USPS-intelligent-barcode/bar_symbol.rb', line 35

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

Instance Attribute Details

#codeInteger (readonly)

Returns the code for this symbol.

Returns:

  • (Integer)

    the code for this symbol



27
28
29
# File 'lib/USPS-intelligent-barcode/bar_symbol.rb', line 27

def code
  @code
end

#letterString (readonly)

Returns the letter for this symbol.

Returns:

  • (String)

    the letter for this symbol



30
31
32
# File 'lib/USPS-intelligent-barcode/bar_symbol.rb', line 30

def letter
  @letter
end

Class Method Details

.make(ascender_bit, descender_bit) ⇒ BarSymbol

Parameters:

  • ascender_bit (Integer)

    (0..1)

  • descender_bit (Integer)

    (0..1)

Returns:



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/USPS-intelligent-barcode/bar_symbol.rb', line 13

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