Class: Unidom::ArticleNumber::Ean13Barcode
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Unidom::ArticleNumber::Ean13Barcode
- Includes:
- Concerns::AsBarcode, Common::Concerns::ModelExtension
- Defined in:
- app/models/unidom/article_number/ean13_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
20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/unidom/article_number/ean13_barcode.rb', line 20 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
31 32 33 |
# File 'app/models/unidom/article_number/ean13_barcode.rb', line 31 def restricted_distribution? self.class::RESTRICTED_DISTRIBUTION_GS1_PREFIXES.include? gs1_prefix end |