Sha256: 8c5fc61b48587f17c9442563dbea89e7f229a695207809dadd0482ff705975b4
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
module GS1 module Barcode # Barcode for boxes in healthcare business. # class Healthcare < Base define_records GTIN, ExpirationDate, Batch, SerialNumber def to_s(level: AIDCMarketingLevels::ENHANCED, separator: DEFAULT_SEPARATOR) return unless valid?(level: level) [ gtin.to_ai, expiration_date&.to_ai, batch&.to_ai, separator, serial_number&.to_ai ].compact.join end def valid?(level: AIDCMarketingLevels::ENHANCED) return false unless AIDCMarketingLevels::ALL.include?(level) validate(level) errors.empty? end private def validate(level) errors.clear validate_minimum return if level == AIDCMarketingLevels::MINIMUM validate_enhanced return if level == AIDCMarketingLevels::ENHANCED validate_highest end def validate_minimum errors << 'Invalid gtin' unless gtin.valid? end def validate_enhanced errors << 'Invalid batch' unless batch&.valid? errors << 'Invalid expiration date' unless expiration_date&.valid? end def validate_highest errors << 'Invalid serial number' unless serial_number&.valid? end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gs1-0.1.5 | lib/gs1/barcode/healthcare.rb |
gs1-0.1.3 | lib/gs1/barcode/healthcare.rb |
gs1-0.1.2 | lib/gs1/barcode/healthcare.rb |