Class: TubeRack
- Inherits:
-
Labware
- Object
- ActiveRecord::Base
- ApplicationRecord
- Asset
- Labware
- TubeRack
- Includes:
- Barcode::Barcodeable
- Defined in:
- app/models/tube_rack.rb
Overview
A rack that holds tubes Tubes are linked via the RackedTubes association
Defined Under Namespace
Classes: Purpose
Constant Summary collapse
- LAYOUTS =
{ 48 => { rows: 6, columns: 8 }, 96 => { rows: 8, columns: 12 } }.freeze
Instance Attribute Summary
Attributes inherited from Labware
Class Method Summary collapse
- .generate_valid_row_values(num_rows) ⇒ Object
- .invalid_coordinates(rack_size, list_coordinates) ⇒ Object
Instance Method Summary collapse
- #after_comment_addition(comment) ⇒ Object
-
#comments ⇒ Object
Comments are proxied as they need to collect comments from various different associations, not just the tubes.
- #number_of_columns ⇒ Object (also: #width)
- #number_of_rows ⇒ Object (also: #height)
-
#receptacles_with_position ⇒ Object
Used to unify interface with TubeRacks.
Methods included from Barcode::Barcodeable
#any_barcode_matching?, #barcode_format, #barcode_number, #cgap_barcode, #cgap_barcode=, #external_barcode, #external_barcode=, #external_identifier, #fluidigm_barcode, #fluidigm_barcode=, #foreign_barcode=, #generate_barcode, included, #infinium_barcode, #infinium_barcode=, #prefix, #primary_barcode, #printable_target, #sanger_barcode
Methods inherited from Labware
#ancestor_of_purpose, #ancestors_of_purpose, #child, #display_name, #external_identifier, find_by_barcode, find_from_any_barcode, #generate_name, #labware, #labwhere_location, labwhere_locations, #parent, #received_date, #retention_instructions, #role, #scanned_in_date, #source_plate, #source_plates, #spiked_in_buffer, #state, #storage_location
Methods included from SharedBehaviour::Named
Methods included from AssetLink::Associations
Methods included from Uuid::Uuidable
included, #unsaved_uuid!, #uuid
Methods inherited from Asset
#ancestor_of_purpose, #asset_type_for_request_types, #barcode_number, #compatible_purposes, #contained_samples, #details, #generate_barcode, #get_qc_result_value_for, #has_stock_asset?, #label, #label=, #original_stock_plates, #prefix, #printable?, #printable_target, #register_stock!, #request_types, #type, #update_from_qc
Methods included from EventfulRecord
#has_many_events, #has_many_lab_events, #has_one_event_with_family
Methods included from Event::PlateEvents
#event_date, #fluidigm_stamp_date, #gel_qc_date, #pico_date, #qc_started_date, #sequenom_stamp_date
Methods inherited from ApplicationRecord
alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!
Methods included from Squishify
Class Method Details
.generate_valid_row_values(num_rows) ⇒ Object
43 44 45 |
# File 'app/models/tube_rack.rb', line 43 def self.generate_valid_row_values(num_rows) ('A'..).first(num_rows) end |
.invalid_coordinates(rack_size, list_coordinates) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/tube_rack.rb', line 30 def self.invalid_coordinates(rack_size, list_coordinates) num_rows = LAYOUTS.fetch(rack_size)[:rows] num_columns = LAYOUTS.fetch(rack_size)[:columns] valid_row_values = generate_valid_row_values(num_rows) valid_column_values = (1..num_columns) list_coordinates.reject do |coordinate| row = coordinate[/[A-Za-z]+/].capitalize column = coordinate[/[0-9]+/] valid_row_values.include?(row) && valid_column_values.cover?(column.to_i) end end |
Instance Method Details
#after_comment_addition(comment) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'app/models/tube_rack.rb', line 69 def after_comment_addition(comment) # We don't let the tubes handle addition to submissions, as if they # all belong to the same submission, we'll get duplicate comments comments.add_comment_to_submissions(comment) # But we still want to add to the tube anyway, as we may have some # tubes that don't have submissions. Or even a mixed rack. comments.add_comment_to_tubes(comment) end |
#comments ⇒ Object
Comments are proxied as they need to collect comments from various different associations, not just the tubes
49 50 51 |
# File 'app/models/tube_rack.rb', line 49 def comments @comments ||= CommentsProxy::TubeRack.new(self) end |
#number_of_columns ⇒ Object Also known as: width
64 65 66 |
# File 'app/models/tube_rack.rb', line 64 def number_of_columns LAYOUTS.fetch(size)[:columns] end |
#number_of_rows ⇒ Object Also known as: height
59 60 61 |
# File 'app/models/tube_rack.rb', line 59 def number_of_rows LAYOUTS.fetch(size)[:rows] end |
#receptacles_with_position ⇒ Object
Used to unify interface with TubeRacks. Returns a list of all receptacles with position information included for aid performance
55 56 57 |
# File 'app/models/tube_rack.rb', line 55 def receptacles_with_position tube_receptacles.includes(:racked_tube) end |