Class: Barcodes::Symbology::Code93
- Defined in:
- lib/barcodes/symbology/code93.rb
Overview
This class represents the Code 93 symbology. Code 93 can encode the characters 0-9 and A-Z along with the following characters: “-”,“.”,“ ”,“$”, “/”,“+”,“%”,“*”
More info: en.wikipedia.org/wiki/Code_93
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
#alpha, #bar_height, #bar_width, #caption_height, #caption_size, #captioned, #color, #data
Class Method Summary collapse
-
.charset ⇒ Object
The Code 93 character set.
-
.valueset ⇒ Object
The Code 93 values set.
Instance Method Summary collapse
-
#caption_data ⇒ Object
Code 39 includes the start and stop symbols in the caption so caption_data is overridden here to return the formatted data string.
-
#checksum ⇒ Object
Calculates the C and K checksum values.
-
#formatted_data ⇒ Object
Start character + data + checksum + stop character.
-
#initialize(args = {}) ⇒ Code93
constructor
Creates a new Code93 instance.
Methods inherited from Base
#encoded_data, #height, #quiet_zone_width, #valid?, #width
Constructor Details
#initialize(args = {}) ⇒ Code93
Creates a new Code93 instance.
50 51 52 53 54 55 |
# File 'lib/barcodes/symbology/code93.rb', line 50 def initialize(args={}) super(args) @start_character = '*' @stop_character = '*' end |
Class Method Details
.charset ⇒ Object
The Code 93 character set
21 22 23 24 25 26 27 28 29 |
# File 'lib/barcodes/symbology/code93.rb', line 21 def self.charset [ "0","1","2","3","4","5","6","7","8","9", "A","B","C","D","E","F","G","H","I","J", "K","L","M","N","O","P","Q","R","S","T", "U","V","W","X","Y","Z","-","."," ","$", "/","+","%","*","\xFC","\xFD","\xFE","\xFF" ].collect {|c| c.bytes.to_a[0] } end |
.valueset ⇒ Object
The Code 93 values set
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/barcodes/symbology/code93.rb', line 32 def self.valueset [ "100010100","101001000","101000100","101000010", "100101000","100100100","100100010","101010000", "100010010","100001010","110101000","110100100", "110100010","110010100","110010010","110001010", "101101000","101100100","101100010","100110100", "100011010","101011000","101001100","101000110", "100101100","100010110","110110100","110110010", "110101100","110100110","110010110","110011010", "101101100","101100110","100110110","100111010", "100101110","111010100","111010010","111001010", "101101110","101110110","110101110","101011110", "100100110","111011010","111010110","100110010" ] end |
Instance Method Details
#caption_data ⇒ Object
Code 39 includes the start and stop symbols in the caption so caption_data is overridden here to return the formatted data string
60 61 62 |
# File 'lib/barcodes/symbology/code93.rb', line 60 def caption_data @start_character + @data + @stop_character end |
#checksum ⇒ Object
Calculates the C and K checksum values
73 74 75 76 77 78 79 |
# File 'lib/barcodes/symbology/code93.rb', line 73 def checksum if self.valid? c_value = self._checksum(@data, 20) k_value = self._checksum(@data + c_value, 15) return c_value + k_value end end |
#formatted_data ⇒ Object
Start character + data + checksum + stop character
65 66 67 68 69 70 |
# File 'lib/barcodes/symbology/code93.rb', line 65 def formatted_data checksum = self.checksum unless checksum.nil? @start_character + @data + checksum + @stop_character end end |