Class: Presenters::TubePresenter

Inherits:
Object
  • Object
show all
Includes:
CreationBehaviour, Presenter, RobotControlled, Statemachine::Shared
Defined in:
app/models/presenters/tube_presenter.rb

Overview

rubocop:todo Style/Documentation

Instance Method Summary collapse

Instance Method Details

#all_plate_statesObject Originally defined in module Statemachine::Shared

#barcodeString Originally defined in module Presenter

Formatted barcode string for display

Returns:

  • (String)

    Barcode string. eg. DN1 12200000123

#child_platesObject Also known as: child_assets



56
57
58
# File 'app/models/presenters/tube_presenter.rb', line 56

def child_plates
  labware.child_plates.tap { |child_plates| yield child_plates if block_given? && child_plates.present? }
end

#comment_titleObject



40
41
42
# File 'app/models/presenters/tube_presenter.rb', line 40

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

#compatible_plate_purposesObject Originally defined in module CreationBehaviour

#compatible_tube_purposesObject Originally defined in module CreationBehaviour

#control_state_changeObject Originally defined in module Statemachine::Shared

Yields to the block if there is the possibility of controlling the state change, passing the valid next states, along with the current one too.

#created_onString Originally defined in module Presenter

Human formatted date of creation

Returns:

  • (String)

    Human formatted date of creation



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'app/models/presenters/tube_presenter.rb', line 82

def csv_file_links
  purpose_config
    .fetch(:file_links, [])
    .map do |link|
      format_extension = link.format || 'csv'
      [
        link.name,
        [
          :limber_tube,
          :tubes_export,
          { id: link.id, limber_tube_id: human_barcode, format: format_extension, **link.params || {} }
        ]
      ]
    end
end

#custom_metadata_fieldsObject



44
45
46
# File 'app/models/presenters/tube_presenter.rb', line 44

def 
  purpose_config.fetch(:custom_metadata_fields, []).to_a.to_json
end

#default_label_countObject Originally defined in module Presenter

#default_printerObject Originally defined in module Presenter

#default_state_change {|default_transition| ... } ⇒ Object Originally defined in module Statemachine::Shared

Yields:

#default_transitionObject Originally defined in module Statemachine::Shared

#each_robotObject Originally defined in module RobotControlled

#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



26
27
28
29
30
# File 'app/models/presenters/tube_presenter.rb', line 26

def label
  # fetch label class from purpose if present
  label_class = purpose_config.fetch(:label_class) || 'Labels::TubeLabel'
  label_class.constantize.new(labware)
end

#printer_limitObject Originally defined in module Presenter

#qc_summaryObject



70
71
72
73
74
75
76
# File 'app/models/presenters/tube_presenter.rb', line 70

def qc_summary
  labware
    .receptacle
    .all_latest_qc
    .sort_by(&:key)
    .each { |result| yield result.key.titleize, result.unit_value.to_s }
end

#qc_summary?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'app/models/presenters/tube_presenter.rb', line 66

def qc_summary?
  labware.receptacle&.all_latest_qc&.to_a.present?
end

#robot?Boolean Originally defined in module RobotControlled

Returns:

  • (Boolean)

#sample_countObject



32
33
34
# File 'app/models/presenters/tube_presenter.rb', line 32

def sample_count
  labware.aliquots.count
end

#sequencescape_submission {|s| ... } ⇒ Object

Yields:

  • (s)


48
49
50
51
52
53
54
# File 'app/models/presenters/tube_presenter.rb', line 48

def sequencescape_submission
  return nil if purpose_config.submission.empty?

  s = SequencescapeSubmission.new(purpose_config.submission.to_hash.merge(assets: [labware.uuid]))
  yield s if block_given?
  s
end

#stateObject Originally defined in module Statemachine::Shared

#state=(value) ⇒ Object Originally defined in module Statemachine::Shared

– We ignore the assignment of the state because that is the statemachine getting in before the plate has been loaded. ++

#suggest_library_passing?Boolean Originally defined in module Presenter

Returns:

  • (Boolean)

#suggested_purposesObject Originally defined in module CreationBehaviour

#summaryObject Originally defined in module Presenter

#tag_sequencesObject



36
37
38
# File 'app/models/presenters/tube_presenter.rb', line 36

def tag_sequences
  labware.aliquots.map(&:tag_pair)
end

#titleObject Originally defined in module Presenter

#transfer_volumes?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'app/models/presenters/tube_presenter.rb', line 78

def transfer_volumes?
  !purpose_config[:transfer_parameters].nil?
end

#tubes_and_sourcesObject



62
63
64
# File 'app/models/presenters/tube_presenter.rb', line 62

def tubes_and_sources
  labware.child_tubes.tap { |child_tubes| yield child_tubes if block_given? && child_tubes.present? }
end