Class: Presenters::TubeRackPresenter

Inherits:
Object
  • Object
show all
Includes:
Presenter, TubeRackWalking
Defined in:
app/models/presenters/tube_rack_presenter.rb

Overview

Basic core presenter class for tube racks Over time, expect this class to use composition to handle the need for different rack presenters based on the tubes within.

Instance Method Summary collapse

Instance Method Details

#barcodeString Originally defined in module Presenter

Formatted barcode string for display

Returns:

  • (String)

    Barcode string. eg. DN1 12200000123

#child_assetsObject Originally defined in module Presenter

#comment_titleObject



65
66
67
# File 'app/models/presenters/tube_rack_presenter.rb', line 65

def comment_title
  "#{human_barcode} - #{purpose_name} : #{tube_purpose_names}"
end

#created_onString Originally defined in module Presenter

Human formatted date of creation

Returns:

  • (String)

    Human formatted date of creation



57
58
59
60
61
62
63
# File 'app/models/presenters/tube_rack_presenter.rb', line 57

def csv_file_links
  purpose_config
    .fetch(:file_links, [])
    .map do |link|
      [link.name, [:limber_tube_rack, :export, { id: link.id, limber_tube_rack_id: human_barcode, format: :csv }]]
    end
end

#default_label_countObject Originally defined in module Presenter

#default_printerObject Originally defined in module Presenter

#input_barcodeString Originally defined in module Presenter

Formatted stock plate barcode string for display

Returns:

  • (String)

    Barcode string. eg. DN1 12200000123

#inspectObject Originally defined in module Presenter

#labelObject



49
50
51
# File 'app/models/presenters/tube_rack_presenter.rb', line 49

def label
  Labels::TubeRackLabel.new(labware)
end

#number_of_tubesObject



69
70
71
# File 'app/models/presenters/tube_rack_presenter.rb', line 69

def number_of_tubes
  all_tubes.count
end

#printer_limitObject Originally defined in module Presenter

#priorityObject



37
38
39
# File 'app/models/presenters/tube_rack_presenter.rb', line 37

def priority
  all_tubes.map(&:priority).max
end

#stateObject

Returns an augmented state of the tube rack. All states take precedence over canceled and failed (in that order or priority) however if we still have a mixed state after that, we display it as such.



26
27
28
29
30
31
32
33
34
35
# File 'app/models/presenters/tube_rack_presenter.rb', line 26

def state
  states = all_tubes.pluck(:state).uniq
  return states.first if states.one?

  %w[cancelled failed].each do |filter|
    states.delete(filter)
    return states.first if states.one?
  end
  'mixed'
end

#suggest_library_passing?Boolean Originally defined in module Presenter

Returns:

  • (Boolean)

#summaryObject Originally defined in module Presenter

#titleObject



41
42
43
# File 'app/models/presenters/tube_rack_presenter.rb', line 41

def title
  "#{purpose_name} : #{tube_purpose_names}"
end

#tube_failing_applicable?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'app/models/presenters/tube_rack_presenter.rb', line 45

def tube_failing_applicable?
  false
end

#tube_labelsObject



53
54
55
# File 'app/models/presenters/tube_rack_presenter.rb', line 53

def tube_labels
  all_tubes.map { |tube| Labels::TubeLabel.new(tube) }
end

#tubes_by_rowObject Originally defined in module TubeRackWalking