Class: Cartesius::Validator
- Inherits:
-
Object
- Object
- Cartesius::Validator
- Defined in:
- lib/cartesius/validator.rb
Class Method Summary collapse
-
.aligned_points(points) ⇒ Object
TODO: cambiare nome…
- .same_points(points) ⇒ Object
Class Method Details
.aligned_points(points) ⇒ Object
TODO: cambiare nome… ne bastano 3 allineati, ma se sono 4 per eccezione ne bastano tre allineati.
13 14 15 16 17 18 19 20 |
# File 'lib/cartesius/validator.rb', line 13 def self.aligned_points(points) if points.count >= 3 line = Line.by_points(point1: points.shift, point2: points.pop) points.each do |point| raise ArgumentError.new('Points must not be aligned!') if line.include?(point) end end end |
.same_points(points) ⇒ Object
6 7 8 9 10 |
# File 'lib/cartesius/validator.rb', line 6 def self.same_points(points) if points.count != points.to_set.count raise ArgumentError.new('Points must be distinct!') end end |