Class: LabelPrinter::Label::BatchTube

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseTube

#assets, #barcode, #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) ⇒ BatchTube

Returns a new instance of BatchTube.



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

def initialize(options)
  super()
  @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/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/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/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/batch_tube.rb', line 5

def stock
  @stock
end

Instance Method Details

#first_line(tube) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/label_printer/label/batch_tube.rb', line 15

def first_line(tube)
  if stock.present?
    tube.name
  else
    tube.respond_to?(:name_for_label) ? tube.name_for_label : tube.name
  end
end

#tubesObject



23
24
25
26
27
28
29
30
31
# File 'lib/label_printer/label/batch_tube.rb', line 23

def tubes
  # If target_asset is a lane, use its parent tube.
  # If stock is present, all label info (including barcode) is about the stock asset;
  # otherwise, all label info is about the target_labware.
  @tubes ||= begin
    targets = requests.map { |r| r.target_asset.is_a?(Lane) ? r.target_labware.parent : r.target_labware }
    stock.present? ? targets.map(&:stock_asset) : targets
  end
end