Class: Barcode::FormatHandlers::SangerBase

Inherits:
Object
  • Object
show all
Defined in:
app/models/barcode/format_handlers.rb

Overview

Base Sequencescape barcode This class mostly wraps the SBCF Gem

Author:

  • jg16

Direct Known Subclasses

SangerCode39, SangerEan13

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(barcode) ⇒ SangerBase

Returns a new instance of SangerBase


24
25
26
# File 'app/models/barcode/format_handlers.rb', line 24

def initialize(barcode)
  @barcode_object = SBCF::SangerBarcode.from_human(barcode)
end

Instance Attribute Details

#barcode_objectObject (readonly)

Returns the value of attribute barcode_object


23
24
25
# File 'app/models/barcode/format_handlers.rb', line 23

def barcode_object
  @barcode_object
end

Instance Method Details

#barcode_prefixObject


53
54
55
# File 'app/models/barcode/format_handlers.rb', line 53

def barcode_prefix
  prefix.human
end

#code128_barcode?Boolean

Returns:

  • (Boolean)

49
50
51
# File 'app/models/barcode/format_handlers.rb', line 49

def code128_barcode?
  true
end

#code39_barcode?Boolean

Returns:

  • (Boolean)

41
42
43
# File 'app/models/barcode/format_handlers.rb', line 41

def code39_barcode?
  true
end

#ean13_barcodeObject

The gem was yielding integers for backward compatible reasons. We'll convert for the time being, but should probably fix that.


33
34
35
# File 'app/models/barcode/format_handlers.rb', line 33

def ean13_barcode
  barcode_object.machine_barcode.to_s
end

#ean13_barcode?Boolean

Returns:

  • (Boolean)

37
38
39
# File 'app/models/barcode/format_handlers.rb', line 37

def ean13_barcode?
  true
end

#number_as_stringObject


45
46
47
# File 'app/models/barcode/format_handlers.rb', line 45

def number_as_string
  number.to_s
end