Class: LabelPrinter::Label::BatchTube

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

Overview

rubocop:todo Style/Documentation

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseTube

#assets, #barcode, #bottom_line, #create_label, #date_today

Methods included from MultipleLabels

#create_labels, #label, #labels, #to_h

Constructor Details

#initialize(options) ⇒ BatchTube

Returns a new instance of BatchTube.


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

def initialize(options)
  @count = options[:count].to_i
  @printable = options[:printable]
  @batch = options[:batch]
  @stock = options[:stock]
end

Instance Attribute Details

#batchObject (readonly)

Returns the value of attribute batch.


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

def batch
  @batch
end

#countObject (readonly)

Returns the value of attribute count.


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

def count
  @count
end

#printableObject (readonly)

Returns the value of attribute printable.


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

def printable
  @printable
end

#stockObject (readonly)

Returns the value of attribute stock.


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

def stock
  @stock
end

Instance Method Details

#middle_line(tube) ⇒ Object


27
28
29
# File 'lib/label_printer/label_printer/label/batch_tube.rb', line 27

def middle_line(tube)
  tube.is_a?(PacBioLibraryTube) ? source_well_position(tube) : super
end

#round_label_bottom_line(tube) ⇒ Object


35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/label_printer/label_printer/label/batch_tube.rb', line 35

def round_label_bottom_line(tube)
  if tube.is_a?(PacBioLibraryTube)
    source_plate = source_plate_barcode(tube)

    # Return the last 4 characters. The fallback handles scenarios where
    # we have fewer than 4 characters in the string, as:
    #     'abc'[-4..] # => nil
    source_plate[-4..] || source_plate
  else
    super
  end
end

#round_label_top_line(tube) ⇒ Object


31
32
33
# File 'lib/label_printer/label_printer/label/batch_tube.rb', line 31

def round_label_top_line(tube)
  tube.is_a?(PacBioLibraryTube) ? source_well_position(tube) : super
end

#top_line(tube) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/label_printer/label_printer/label/batch_tube.rb', line 14

def top_line(tube)
  if stock.present?
    tube.name
  elsif batch.multiplexed?
    tag_range = tube.receptacle.tag_range
    tag_range.nil? ? tube.name : "(#{tag_range}) #{tube.id}"
  elsif tube.is_a? PacBioLibraryTube
    source_plate_barcode(tube)
  else
    tube.name_for_label
  end
end

#tubesObject

rubocop:todo Metrics/PerceivedComplexity


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/label_printer/label_printer/label/batch_tube.rb', line 49

def tubes # rubocop:todo Metrics/AbcSize
  @tubes ||=
    if stock.present?
      if batch.multiplexed?
        # all info on a label including barcode is about target_asset first child
        requests.map { |request| request.target_labware.children.first }
      else
        # all info on a label including barcode is about target_asset stock asset
        requests.map { |request| request.target_labware.stock_asset }
      end
    else
      # all info on a label including barcode is about target_asset
      requests.map(&:target_labware)
    end
end