Class: Unidom::ArticleNumber::Ean8Barcode
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Unidom::ArticleNumber::Ean8Barcode
- Includes:
- Concerns::AsBarcode, Common::Concerns::ModelExtension
- Defined in:
- app/models/unidom/article_number/ean8_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
22 23 24 25 26 27 28 29 30 |
# File 'app/models/unidom/article_number/ean8_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 :item_reference, code[3..6] write_attribute :check_digit, code[7] end end |
#restricted_distribution? ⇒ Boolean
32 33 34 |
# File 'app/models/unidom/article_number/ean8_barcode.rb', line 32 def restricted_distribution? self.class::RESTRICTED_DISTRIBUTION_GS1_PREFIXES.include? gs1_prefix end |