Class: GS1::Barcode::Base
- Inherits:
-
Object
- Object
- GS1::Barcode::Base
- Includes:
- Definitions
- Defined in:
- lib/gs1/barcode/base.rb
Overview
Base class for a barcode.
Direct Known Subclasses
Class Method Summary collapse
- .from_scan(barcode, separator: GS1.configuration.barcode_separator) ⇒ Object
- .from_scan!(barcode, separator: GS1.configuration.barcode_separator) ⇒ Object
- .scan_to_params(barcode, separator: GS1.configuration.barcode_separator) ⇒ Object
- .scan_to_params!(barcode, separator: GS1.configuration.barcode_separator) ⇒ Object
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
Methods included from Definitions
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 14 15 16 |
# File 'lib/gs1/barcode/base.rb', line 8 def initialize( = {}) @params_order = .keys self.class.records.each do |record| data = .fetch(record.underscore_name, nil) instance_variable_set("@#{record.underscore_name}", record.new(data)) end end |
Class Method Details
.from_scan(barcode, separator: GS1.configuration.barcode_separator) ⇒ Object
27 28 29 |
# File 'lib/gs1/barcode/base.rb', line 27 def from_scan(, separator: GS1.configuration.) new(scan_to_params(, separator: separator)) end |
.from_scan!(barcode, separator: GS1.configuration.barcode_separator) ⇒ Object
23 24 25 |
# File 'lib/gs1/barcode/base.rb', line 23 def from_scan!(, separator: GS1.configuration.) new(scan_to_params!(, separator: separator)) end |
.scan_to_params(barcode, separator: GS1.configuration.barcode_separator) ⇒ Object
35 36 37 |
# File 'lib/gs1/barcode/base.rb', line 35 def scan_to_params(, separator: GS1.configuration.) Tokenizer.new(, separator: separator).to_params end |
.scan_to_params!(barcode, separator: GS1.configuration.barcode_separator) ⇒ Object
31 32 33 |
# File 'lib/gs1/barcode/base.rb', line 31 def scan_to_params!(, separator: GS1.configuration.) Tokenizer.new(, separator: separator).to_params! end |
Instance Method Details
#errors ⇒ Object
18 19 20 |
# File 'lib/gs1/barcode/base.rb', line 18 def errors @errors ||= [] end |