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 17 |
# File 'lib/gs1/barcode/base.rb', line 8 def initialize( = {}) .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 = .to_h.keys end |
Class Method Details
.from_scan(barcode, separator: GS1.configuration.barcode_separator) ⇒ Object
28 29 30 |
# File 'lib/gs1/barcode/base.rb', line 28 def from_scan(, separator: GS1.configuration.) new(scan_to_params(, separator: separator)) end |
.from_scan!(barcode, separator: GS1.configuration.barcode_separator) ⇒ Object
24 25 26 |
# File 'lib/gs1/barcode/base.rb', line 24 def from_scan!(, separator: GS1.configuration.) new(scan_to_params!(, separator: separator)) end |
.scan_to_params(barcode, separator: GS1.configuration.barcode_separator) ⇒ Object
36 37 38 |
# File 'lib/gs1/barcode/base.rb', line 36 def scan_to_params(, separator: GS1.configuration.) Tokenizer.new(, separator: separator).to_params end |
.scan_to_params!(barcode, separator: GS1.configuration.barcode_separator) ⇒ Object
32 33 34 |
# File 'lib/gs1/barcode/base.rb', line 32 def scan_to_params!(, separator: GS1.configuration.) Tokenizer.new(, separator: separator).to_params! end |