Class: Unidom::ArticleNumber::Code128Barcode
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Unidom::ArticleNumber::Code128Barcode
- Includes:
- Common::Concerns::ModelExtension
- Defined in:
- app/models/unidom/article_number/code_128_barcode.rb
Overview
Code 128 条形码是高密度条形码符号。en.wikipedia.org/wiki/Code_128 Code 128 A 条形码 code set: ASCII characters 00 to 95 (0-9, A-Z and control codes), special characters, and FNC 1-4. Code 128 B 条形码 code set: ASCII characters 32 to 127 (0-9, A-Z, a-z), special characters, and FNC 1-4. Code 128 C 条形码 code set: 00-99 (encodes each two digits with one code) and FNC1.
Instance Method Summary collapse
Instance Method Details
#weighted_modulo_103_checksum(codes) ⇒ Object
19 20 21 22 23 |
# File 'app/models/unidom/article_number/code_128_barcode.rb', line 19 def weighted_modulo_103_checksum(codes) sum = 103 codes.each_with_index do |char, index| sum += (char.unpack('C').first-32)*(index+1) end sum%103 end |