Class: LabwareBarcode
- Inherits:
-
Object
- Object
- LabwareBarcode
- Defined in:
- lib/labware_barcode.rb
Overview
Wraps labware barcodes to assist with rendering and to provide a cleaner interface
Instance Attribute Summary collapse
-
#ean13 ⇒ Object
readonly
Returns the value of attribute ean13.
-
#human ⇒ Object
readonly
Returns the value of attribute human.
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
Instance Method Summary collapse
-
#=~(other) ⇒ Bool
Match operator.
-
#initialize(human:, machine:, ean13: nil) ⇒ LabwareBarcode
constructor
A new instance of LabwareBarcode.
- #number ⇒ Object
- #prefix ⇒ Object
- #to_s ⇒ Object
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
#ean13 ⇒ Object (readonly)
Returns the value of attribute ean13.
5 6 7 |
# File 'lib/labware_barcode.rb', line 5 def ean13 @ean13 end |
#human ⇒ Object (readonly)
Returns the value of attribute human.
5 6 7 |
# File 'lib/labware_barcode.rb', line 5 def human @human end |
#machine ⇒ Object (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).
38 39 40 |
# File 'lib/labware_barcode.rb', line 38 def =~(other) sbcf.valid? ? sbcf =~ other : machine == other end |
#number ⇒ Object
13 14 15 |
# File 'lib/labware_barcode.rb', line 13 def number extracted && extracted[:number] end |
#prefix ⇒ Object
17 18 19 |
# File 'lib/labware_barcode.rb', line 17 def prefix extracted && extracted[:prefix] end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/labware_barcode.rb', line 21 def to_s @human end |