Class: Barcodes::Symbology::Codabar

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

Overview

This class represents the Codabar symbology. Codabar can encode the numbers 0-9 and the following symbols: -,$,:,/,.,+

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

Instance Attribute Summary collapse

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 = {}) ⇒ Codabar

Creates a new Codabar instance with given arguments.



42
43
44
45
46
47
48
49
50
51
# File 'lib/barcodes/symbology/codabar.rb', line 42

def initialize(args={})
  unless args.has_key? :start_character
    args[:start_character] = 'A'
  end
  unless args.has_key? :stop_character
    args[:stop_character] = 'B'
  end
  
  super(args)
end

Instance Attribute Details

#start_characterObject

Start character



20
21
22
# File 'lib/barcodes/symbology/codabar.rb', line 20

def start_character
  @start_character
end

#stop_characterObject

Stop character



23
24
25
# File 'lib/barcodes/symbology/codabar.rb', line 23

def stop_character
  @stop_character
end

Class Method Details

.charsetObject

Codabar character set (0-9,-,$,:,/,.,+)



26
27
28
# File 'lib/barcodes/symbology/codabar.rb', line 26

def self.charset
  ['0','1','2','3','4','5','6','7','8','9','-','$',':','/','.','+','A','B','C','D'].collect {|c| c.bytes.to_a[0] }
end

.valuesetObject

Codabar values set



31
32
33
34
35
36
37
38
39
# File 'lib/barcodes/symbology/codabar.rb', line 31

def self.valueset
  [
    '1010100110','1010110010','1010010110','110010101',
    '101101001','110101001','100101011','100101101',
    '100110101','110100101','101001101','101100101',
    '1101011011','1101101011','1101101101','101100110011',
    '1011001001','1010010011','1001001011','1010011001'
  ]
end

Instance Method Details

#formatted_dataObject

Start character + data + stop character



54
55
56
# File 'lib/barcodes/symbology/codabar.rb', line 54

def formatted_data
  @start_character + @data + @stop_character
end