Class: LabelPrinter::Label::SampleManifestTube

Inherits:
BaseTube
  • Object
show all
Defined in:
lib/label_printer/label/sample_manifest_tube.rb

Instance Attribute Summary collapse

Attributes included from MultipleLabels

#count

Instance Method Summary collapse

Methods inherited from BaseTube

#assets, #build_label, #date_today, #round_label_bottom_line, #round_label_top_line, #second_line, #third_line

Methods included from MultipleLabels

#create_labels, #labels

Constructor Details

#initialize(options) ⇒ SampleManifestTube

Initialised only for 1dtube and library



8
9
10
11
12
13
# File 'lib/label_printer/label/sample_manifest_tube.rb', line 8

def initialize(options)
  super()
  @sample_manifest = options[:sample_manifest]
  @only_first_label = options[:only_first_label]
  @barcode_type = options[:barcode_type]
end

Instance Attribute Details

#only_first_labelObject (readonly)

Returns the value of attribute only_first_label.



5
6
7
# File 'lib/label_printer/label/sample_manifest_tube.rb', line 5

def only_first_label
  @only_first_label
end

#sample_manifestObject (readonly)

Returns the value of attribute sample_manifest.



5
6
7
# File 'lib/label_printer/label/sample_manifest_tube.rb', line 5

def sample_manifest
  @sample_manifest
end

Instance Method Details

#barcode(tube) ⇒ String

Returns the appropriate barcode for the given tube based on the barcode type.

Parameters:

  • tube (Tube)

    The tube object for which the barcode is being retrieved. It is expected to respond to human_barcode and machine_barcode.

Returns:

  • (String)

    The human-readable barcode if the barcode type is '2D Barcode', otherwise the machine-readable barcode.



21
22
23
24
25
26
27
# File 'lib/label_printer/label/sample_manifest_tube.rb', line 21

def barcode(tube)
  if @barcode_type == Rails.application.config.tube_manifest_barcode_config[:barcode_type_labels]['2d']
    return tube.human_barcode
  end

  tube.machine_barcode
end

#first_line(_tube = nil) ⇒ Object



29
30
31
# File 'lib/label_printer/label/sample_manifest_tube.rb', line 29

def first_line(_tube = nil)
  sample_manifest.study.abbreviation
end

#tubesObject



33
34
35
36
37
# File 'lib/label_printer/label/sample_manifest_tube.rb', line 33

def tubes
  return [sample_manifest.printables.first] if only_first_label

  sample_manifest.printables
end