Class: Presenters::TubesWithSources
- Inherits:
-
Object
- Object
- Presenters::TubesWithSources
- Defined in:
- app/models/presenters/tubes_with_sources.rb
Overview
Groups tubes with the wells that get transferred into them Used by the plate presenter to ensure consistent colour-coding and annotation with source well information
Defined Under Namespace
Classes: Collection
Instance Attribute Summary collapse
-
#tube ⇒ Object
readonly
Returns the value of attribute tube.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(well) ⇒ Object
-
#initialize(tube, pools) ⇒ TubesWithSources
constructor
A new instance of TubesWithSources.
-
#pool_id ⇒ Object
Returns the pool id based on the shared submission between the wells.
- #pool_index ⇒ Object
- #pool_size ⇒ Object
- #source_locations ⇒ Object
Constructor Details
#initialize(tube, pools) ⇒ TubesWithSources
Returns a new instance of TubesWithSources.
50 51 52 53 54 |
# File 'app/models/presenters/tubes_with_sources.rb', line 50 def initialize(tube, pools) @tube = tube @pools = pools @sources = [] end |
Instance Attribute Details
#tube ⇒ Object (readonly)
Returns the value of attribute tube.
48 49 50 |
# File 'app/models/presenters/tubes_with_sources.rb', line 48 def tube @tube end |
Class Method Details
.build(wells:, pools:) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/presenters/tubes_with_sources.rb', line 35 def self.build(wells:, pools:) Collection.new( wells .each_with_object({}) do |well, store| well.downstream_tubes.each do |tube| store[tube] ||= new(tube, pools) store[tube] << well end end .values ) end |
Instance Method Details
#<<(well) ⇒ Object
56 57 58 |
# File 'app/models/presenters/tubes_with_sources.rb', line 56 def <<(well) @sources << well end |
#pool_id ⇒ Object
Returns the pool id based on the shared submission between the wells
61 62 63 |
# File 'app/models/presenters/tubes_with_sources.rb', line 61 def pool_id @sources.map(&:submission_ids).reduce { |common_ids, current_ids| common_ids & current_ids }.first end |
#pool_index ⇒ Object
65 66 67 |
# File 'app/models/presenters/tubes_with_sources.rb', line 65 def pool_index @pools.pool_index(pool_id) end |
#pool_size ⇒ Object
73 74 75 |
# File 'app/models/presenters/tubes_with_sources.rb', line 73 def pool_size @sources.sum { |well| well.aliquots.count } end |
#source_locations ⇒ Object
69 70 71 |
# File 'app/models/presenters/tubes_with_sources.rb', line 69 def source_locations @sources.map(&:location) end |