class GS1::Barcode::Base
Base
class for a barcode.
Public Class Methods
from_scan(barcode, separator: GS1.configuration.barcode_separator)
click to toggle source
# File lib/gs1/barcode/base.rb, line 28 def from_scan(barcode, separator: GS1.configuration.barcode_separator) new(scan_to_params(barcode, separator: separator)) end
from_scan!(barcode, separator: GS1.configuration.barcode_separator)
click to toggle source
# File lib/gs1/barcode/base.rb, line 24 def from_scan!(barcode, separator: GS1.configuration.barcode_separator) new(scan_to_params!(barcode, separator: separator)) end
new(options = {})
click to toggle source
# File lib/gs1/barcode/base.rb, line 8 def initialize(options = {}) options.each do |(attribute_name, data)| validate_attribute_data(attribute_name) validate_attribute_record(attribute_name) do |record| instance_variable_set("@#{attribute_name}", record.new(data)) end end @params_order = options.to_h.keys end
scan_to_params(barcode, separator: GS1.configuration.barcode_separator)
click to toggle source
# File lib/gs1/barcode/base.rb, line 36 def scan_to_params(barcode, separator: GS1.configuration.barcode_separator) Tokenizer.new(barcode, separator: separator).to_params end
scan_to_params!(barcode, separator: GS1.configuration.barcode_separator)
click to toggle source
# File lib/gs1/barcode/base.rb, line 32 def scan_to_params!(barcode, separator: GS1.configuration.barcode_separator) Tokenizer.new(barcode, separator: separator).to_params! end
Public Instance Methods
errors()
click to toggle source
# File lib/gs1/barcode/base.rb, line 19 def errors @errors ||= Errors.new end