Class: BarcodeCheck

Inherits:
Object
  • Object
show all
Defined in:
common/barcode_check.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#maxObject (readonly)

Returns the value of attribute max



3
4
5
# File 'common/barcode_check.rb', line 3

def max
  @max
end

#minObject (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

Returns:

  • (Boolean)


22
23
24
# File 'common/barcode_check.rb', line 22

def valid?(barcode)
  !barcode || (min..max).cover?(barcode.length)
end