Class: BarcodeCheck
- Inherits:
-
Object
- Object
- BarcodeCheck
- Defined in:
- common/barcode_check.rb
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
Instance Method Summary collapse
-
#initialize(repo_code) ⇒ BarcodeCheck
constructor
A new instance of BarcodeCheck.
-
#valid?(barcode) ⇒ Boolean
Constructor Details
#initialize(repo_code) ⇒ BarcodeCheck
Returns a new instance of BarcodeCheck.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'common/barcode_check.rb', line 5 def initialize(repo_code) @min = 0 @max = 255 return if !AppConfig.has_key?(:container_management_barcode_length) cfg = AppConfig[:container_management_barcode_length] [:system_default, repo_code].each do |key| if cfg.has_key?(key) @min = cfg[key][:min].to_i if cfg[key].has_key?(:min) @max = cfg[key][:max].to_i if cfg[key].has_key?(:max) end end end |
Instance Attribute Details
#max ⇒ Object (readonly)
Returns the value of attribute max
3 4 5 |
# File 'common/barcode_check.rb', line 3 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min
3 4 5 |
# File 'common/barcode_check.rb', line 3 def min @min end |
Instance Method Details
#valid?(barcode) ⇒ Boolean
22 23 24 |
# File 'common/barcode_check.rb', line 22 def valid?() ! || (min..max).cover?(.length) end |