Module: SBCF::Builders

Included in:
SangerBarcode
Defined in:
lib/sanger_barcode_format/builders.rb

Overview

Provide class methods to assist with creation of barcodes from Different formats

Instance Method Summary collapse

Instance Method Details

#from_human(human_barcode, checksum_required = false) ⇒ Object

Provide a human barcode eg. 'PR1234K' and returns a SangerBarcode object checksum_required = set to true to reject barcodes without a checksum Raises InvalidBarcode if the format doesn't match raises ChecksumRequired if the checksum is missing, yet checksum_required is true


9
10
11
# File 'lib/sanger_barcode_format/builders.rb', line 9

def from_human(human_barcode, checksum_required = false)
  SangerBarcode.new(human_barcode: human_barcode, checksum_required: checksum_required)
end

#from_machine(machine_barcode) ⇒ Object

Provide a full 13 digit ean13 barcode and returns a SangerBarcode object Raises InvalidBarcode if the barcode isn't 12-13 digits long


15
16
17
# File 'lib/sanger_barcode_format/builders.rb', line 15

def from_machine(machine_barcode)
  SangerBarcode.new(machine_barcode: machine_barcode)
end

#from_prefix_and_number(human_prefix, short_barcode) ⇒ Object


19
20
21
# File 'lib/sanger_barcode_format/builders.rb', line 19

def from_prefix_and_number(human_prefix, short_barcode)
  SangerBarcode.new(prefix: human_prefix, number: short_barcode)
end