class Imb::BarMap
Maps intelligent barcode “characters” to the actual barcode.
Public Class Methods
new()
click to toggle source
# File lib/usps_intelligent_barcode/bar_map.rb, line 10 def initialize @mapping = load_mapping end
Public Instance Methods
symbols(characters)
click to toggle source
Given an array of intelligent barcode “characters”, return an the symbols for each position.
@param characters [Array<Integer>] array of 13-bit “characters”
between 0 and 1364
@return [Array<BarSymbol>] array of symbols,
e.g. [BarSymbol::TRACKER, BarSymbol::ASCENDER, ...]
# File lib/usps_intelligent_barcode/bar_map.rb, line 21 def symbols(characters) @mapping.map do |bar_position| bar_position.map(characters) end end
Private Instance Methods
convert_mapping_data(mapping_data)
click to toggle source
# File lib/usps_intelligent_barcode/bar_map.rb, line 33 def convert_mapping_data(mapping_data) mapping_data.map do |descender, ascender| descender_character_position = CharacterPosition.new(*descender) ascender_character_position = CharacterPosition.new(*ascender) BarPosition.new( descender_character_position, ascender_character_position, ) end end
load_mapping()
click to toggle source
# File lib/usps_intelligent_barcode/bar_map.rb, line 29 def load_mapping convert_mapping_data(load_mapping_data) end
load_mapping_data()
click to toggle source
# File lib/usps_intelligent_barcode/bar_map.rb, line 44 def load_mapping_data YAML.load_file(mapping_path) end
mapping_path()
click to toggle source
# File lib/usps_intelligent_barcode/bar_map.rb, line 48 def mapping_path File.expand_path('bar_to_character_mapping.yml', File.dirname(__FILE__)) end