Class: GS1::Barcode::Healthcare

Inherits:
Base
  • Object
show all
Defined in:
lib/gs1/barcode/healthcare.rb

Overview

Barcode for boxes in healthcare business.

Instance Method Summary collapse

Methods inherited from Base

#errors, from_scan, from_scan!, #initialize, scan_to_params, scan_to_params!

Methods included from Definitions

included

Constructor Details

This class inherits a constructor from GS1::Barcode::Base

Instance Method Details

#to_s(level: AIDCMarketingLevels::ENHANCED, separator: GS1.configuration.barcode_separator) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gs1/barcode/healthcare.rb', line 8

def to_s(level: AIDCMarketingLevels::ENHANCED, separator: GS1.configuration.barcode_separator)
  return unless valid?(level: level)

  @params_order.each_with_object('') do |param, out|
    record = send(param)

    next unless record.to_ai

    out << record.to_ai
    out << separator if record.class.separator? && param != @params_order.last
  end
end

#valid?(level: AIDCMarketingLevels::ENHANCED) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/gs1/barcode/healthcare.rb', line 21

def valid?(level: AIDCMarketingLevels::ENHANCED)
  return false unless AIDCMarketingLevels::ALL.include?(level)

  validate(level)

  errors.empty?
end