Class: Unidom::ArticleNumber::Ean13Barcode
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Unidom::ArticleNumber::Ean13Barcode
- Includes:
- Common::ModelExtension
- Defined in:
- app/models/unidom/article_number/ean_13_barcode.rb
Overview
EAN-13 Barcode 是13位条形码。en.wikipedia.org/wiki/EAN-13 en.wikipedia.org/wiki/International_Article_Number_(EAN)
Constant Summary collapse
- RESTRICTED_DISTRIBUTION_GS1_PREFIXES =
(('020'..'029').to_a + ('040'..'049').to_a + ('200'..'299').to_a).freeze
Instance Method Summary collapse
Instance Method Details
#code=(code) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/unidom/article_number/ean_13_barcode.rb', line 22 def code=(code) code = code.to_s write_attribute :code, code if code.present? write_attribute :gs1_prefix, code[0..2] write_attribute :company_number, code[3..6] write_attribute :item_reference, code[7..11] write_attribute :check_digit, code[12] end end |
#restricted_distribution? ⇒ Boolean
33 34 35 |
# File 'app/models/unidom/article_number/ean_13_barcode.rb', line 33 def restricted_distribution? self.class::RESTRICTED_DISTRIBUTION_GS1_PREFIXES.include? gs1_prefix end |