Class: LabwareBarcode

Inherits:
Object
  • Object
show all
Defined in:
lib/labware_barcode.rb

Overview

Wraps labware barcodes to assist with rendering and to provide a cleaner interface

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(human:, machine:, ean13: nil) ⇒ LabwareBarcode

Returns a new instance of LabwareBarcode.



7
8
9
10
11
# File 'lib/labware_barcode.rb', line 7

def initialize(human:, machine:, ean13: nil)
  @human = human
  @machine = machine
  @ean13 = ean13
end

Instance Attribute Details

#ean13Object (readonly)

Returns the value of attribute ean13.



5
6
7
# File 'lib/labware_barcode.rb', line 5

def ean13
  @ean13
end

#humanObject (readonly)

Returns the value of attribute human.



5
6
7
# File 'lib/labware_barcode.rb', line 5

def human
  @human
end

#machineObject (readonly)

Returns the value of attribute machine.



5
6
7
# File 'lib/labware_barcode.rb', line 5

def machine
  @machine
end

Instance Method Details

#=~(other) ⇒ Bool

Match operator. Checks to see if the other barcode, is a match for this one.

  • In the case of foreign barcodes we match only when the other barcode is equal to the machine_barcode

rubocop:todo Layout/LineLength

  • In the case of SBCF formatted barcodes (eg DN1234K/1220001234757) we delegate to the matcher in SBCF::SangerBarcode

rubocop:enable Layout/LineLength

This allows us to match either ean13 or code39 formatted barcodes (or the machine barcode to human readable
version in the case of older plates).

Parameters:

  • other (String)

    The barcode to check

Returns:

  • (Bool)

    True is the barcodes match, false otherwise.



38
39
40
# File 'lib/labware_barcode.rb', line 38

def =~(other)
  sbcf.valid? ? sbcf =~ other : machine == other
end

#numberObject



13
14
15
# File 'lib/labware_barcode.rb', line 13

def number
  extracted && extracted[:number]
end

#prefixObject



17
18
19
# File 'lib/labware_barcode.rb', line 17

def prefix
  extracted && extracted[:prefix]
end

#to_sObject



21
22
23
# File 'lib/labware_barcode.rb', line 21

def to_s
  @human
end