Class: LabelPrinter::Label::BatchTube

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

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


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

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


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

def batch
  @batch
end

#countObject (readonly)

Returns the value of attribute count


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

def count
  @count
end

#printableObject (readonly)

Returns the value of attribute printable


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

def printable
  @printable
end

#stockObject (readonly)

Returns the value of attribute stock


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

def stock
  @stock
end

Instance Method Details

#middle_line(tube) ⇒ Object


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

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

#round_label_bottom_line(tube) ⇒ Object


34
35
36
# File 'lib/label_printer/label_printer/label/batch_tube.rb', line 34

def round_label_bottom_line(tube)
  (tube.is_a? PacBioLibraryTube) ? source_plate_barcode(tube).split(//).last(4).join : super
end

#round_label_top_line(tube) ⇒ Object


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

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

#top_line(tube) ⇒ Object


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

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


38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/label_printer/label_printer/label/batch_tube.rb', line 38

def tubes
  @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 { |request| request.target_labware }
              end
end