Class: Imb::CharacterPosition

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

Overview

Represents the position of one bit in the array of intelligent barcode “characters”.

Internal collapse

Constructor Details

#initialize(character_index, bit_number) ⇒ CharacterPosition

Returns a new instance of CharacterPosition.

Parameters:

  • character_index (Integer)
  • bit_number (Integer)


13
14
15
16
# File 'lib/USPS-intelligent-barcode/character_position.rb', line 13

def initialize(character_index, bit_number)
  @character_index = character_index
  @bit_number = bit_number
end

Instance Method Details

#extract_bit_from_characters(characters) ⇒ Integer

Given an array of characters, return the bit for this position.

Parameters:

  • characters ([Integer])

Returns:

  • (Integer)

    bit (0 or 1)



22
23
24
# File 'lib/USPS-intelligent-barcode/character_position.rb', line 22

def extract_bit_from_characters(characters)
  characters[@character_index][@bit_number]
end