Class: BioPlates::Plate::Well
- Inherits:
-
Object
- Object
- BioPlates::Plate::Well
- Defined in:
- lib/bio-plates/plates.rb
Constant Summary collapse
- @@regexp =
/(?<row>[A-Za-z]+)(?<column>\d+)/
- @@nrow =
Better not to hard code theseā¦
8
- @@ncol =
12
Instance Attribute Summary collapse
-
#annotation ⇒ Object
Returns the value of attribute annotation.
-
#column ⇒ Object
Returns the value of attribute column.
-
#row ⇒ Object
Returns the value of attribute row.
-
#well ⇒ Object
Returns the value of attribute well.
Instance Method Summary collapse
- #index! ⇒ Object
-
#initialize(hash) ⇒ Well
constructor
A new instance of Well.
- #quadrantize(plate) ⇒ Object
- #quadrantize!(plate) ⇒ Object
Constructor Details
#initialize(hash) ⇒ Well
Returns a new instance of Well.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/bio-plates/plates.rb', line 123 def initialize(hash) if hash[:row] && hash[:column] @row = hash[:row] @column = hash[:column].to_s else # Split the well annotation if row & col not given separately m = hash[:well].match(@@regexp) @well = hash[:well] @row = m[:row] @column = m[:column] end # NB annotation includes the original well annotation @annotation = hash.delete_if{|k,f| [:row, :column, :well].include? k}.to_h end |
Instance Attribute Details
#annotation ⇒ Object
Returns the value of attribute annotation.
118 119 120 |
# File 'lib/bio-plates/plates.rb', line 118 def annotation @annotation end |
#column ⇒ Object
Returns the value of attribute column.
118 119 120 |
# File 'lib/bio-plates/plates.rb', line 118 def column @column end |
#row ⇒ Object
Returns the value of attribute row.
118 119 120 |
# File 'lib/bio-plates/plates.rb', line 118 def row @row end |
#well ⇒ Object
Returns the value of attribute well.
118 119 120 |
# File 'lib/bio-plates/plates.rb', line 118 def well @well end |
Instance Method Details
#index! ⇒ Object
139 140 141 |
# File 'lib/bio-plates/plates.rb', line 139 def index! @well = @row.upcase.to_s + @column end |
#quadrantize(plate) ⇒ Object
155 156 157 158 |
# File 'lib/bio-plates/plates.rb', line 155 def quadrantize(plate) dup = self.dup dup.quadrantize!(plate) end |
#quadrantize!(plate) ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/bio-plates/plates.rb', line 143 def quadrantize!(plate) self.index! unless @well @annotation[:original_well] = @well @annotation[:original_plate] = @annotation[:plate] @annotation.delete(:plate) # Remove so no conflict with new plate (plate == 2 || plate == 4) ? inc = 1 : inc = 0 (plate == 3 || plate == 4) ? rowinc = 1 : rowinc = 0 @column = (@column.to_i + [*0..@@ncol][@column.to_i-1]+inc).to_s @row = (@row.ord + [*0..@@nrow][@row.upcase.ord-65]+rowinc).chr # 65 = ASCII "A" self end |