Module: CaTissue::Position
- Included in:
- AbstractPosition, SpecimenArrayContent
- Defined in:
- lib/catissue/helpers/position.rb
Overview
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Whether other is an instance of this position’s class with the same occupant and equal location.
-
#coordinate ⇒ Coordinate
The read-only coordinate with this AbstractPosition’s Location#row and Location#column.
-
#location ⇒ Location
The location of this Position.
- #location=(value) ⇒ Object
-
#to_a ⇒ (Integer, Integer)
This Position’s zero-based (Location#column, Location#row) tuple.
-
#unspecified? ⇒ Boolean
Whether either the column or the row is nil.
- #validate_local ⇒ Object
Instance Method Details
#==(other) ⇒ Boolean
Returns whether other is an instance of this position’s class with the same occupant and equal location.
14 15 16 |
# File 'lib/catissue/helpers/position.rb', line 14 def ==(other) self.class === other and occupant == other.occupant and location == other.location end |
#coordinate ⇒ Coordinate
Returns the read-only coordinate with this AbstractPosition’s Location#row and Location#column.
20 21 22 |
# File 'lib/catissue/helpers/position.rb', line 20 def coordinate location.coordinate end |
#location ⇒ Location
Returns the location of this Position.
25 26 27 28 29 30 31 32 |
# File 'lib/catissue/helpers/position.rb', line 25 def location @location ||= Location.new # always ensure that the location is consistent with the Java state @location.holder = holder @location.row = row @location.column = column @location end |
#location=(value) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/catissue/helpers/position.rb', line 35 def location=(value) @location = value || Location.new self.holder = @location.holder self.row = @location.row self.column = @location.column end |
#to_a ⇒ (Integer, Integer)
Returns this Position’s zero-based (Location#column, Location#row) tuple.
49 50 51 |
# File 'lib/catissue/helpers/position.rb', line 49 def to_a [column, row] end |
#unspecified? ⇒ Boolean
Returns whether either the column or the row is nil.
43 44 45 |
# File 'lib/catissue/helpers/position.rb', line 43 def unspecified? column.nil? or row.nil? end |
#validate_local ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/catissue/helpers/position.rb', line 54 def validate_local super logger.debug { "Validating that #{holder} can hold #{occupant}..." } curr_occ = holder[column, row] if curr_occ.nil? then unless holder.can_hold_child?(occupant) then reason = holder.full? ? "it is full" : "the occupant type is not among the supported types #{holder.container_type.child_types.qp}" raise Jinx::ValidationError.new("#{holder} cannot hold #{occupant} since #{reason}") end elsif curr_occ != occupant raise Jinx::ValidationError.new("#{holder} cannot hold #{occupant} since the location #{[colum, row]} is already occupied by #{curr_occ}") end end |