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
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
24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/unidom/article_number/ean13_barcode.rb', line 24 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
35 36 37 |
# File 'app/models/unidom/article_number/ean13_barcode.rb', line 35 def restricted_distribution? self.class::RESTRICTED_DISTRIBUTION_GS1_PREFIXES.include? gs1_prefix end |