Class: Barcodes::Symbology::Interleaved2Of5

Inherits:
Base
  • Object
show all
Defined in:
lib/barcodes/symbology/interleaved2of5.rb

Overview

This class represents the Interleaved 2 of 5 symbology Interleaved 2 of 5 can encode only numbers 0-9

More info: en.wikipedia.org/wiki/Interleaved_2_of_5

Direct Known Subclasses

Interleaved2Of5Mod10

Instance Attribute Summary

Attributes inherited from Base

#alpha, #bar_height, #bar_width, #caption_height, #caption_size, #captioned, #color, #data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#caption_data, #encoded_data, #height, #quiet_zone_width, #valid?, #width

Constructor Details

#initialize(args = {}) ⇒ Interleaved2Of5

Creates a new Interleaved2Of5 instance Interleaved 2 of 5 must have the start and stop characters ‘S’ and ‘E’ so they are overridden here.



35
36
37
38
39
40
# File 'lib/barcodes/symbology/interleaved2of5.rb', line 35

def initialize(args={})
  super(args)
  
  @start_character = 'S'
  @stop_character = 'E'
end

Class Method Details

.charsetObject

Interleaved 2 of 5 character set



19
20
21
# File 'lib/barcodes/symbology/interleaved2of5.rb', line 19

def self.charset
  ['0','1','2','3','4','5','6','7','8','9','S','E'].collect {|c| c.bytes.to_a[0] }
end

.valuesetObject

Interleaved 2 of 5 values set



24
25
26
27
28
29
30
# File 'lib/barcodes/symbology/interleaved2of5.rb', line 24

def self.valueset
  [
    '101011011010','110101010110','101101010110','110110101010',
    '101011010110','110101101010','101101101010','101010110110',
    '110101011010','101101011010','1010','1101'
  ]
end

Instance Method Details

#formatted_dataObject

Returns start character + data + stop character



43
44
45
# File 'lib/barcodes/symbology/interleaved2of5.rb', line 43

def formatted_data
  @start_character + @data + @stop_character
end