Class: Mindee::Geometry::Quadrilateral
- Inherits:
-
Object
- Object
- Mindee::Geometry::Quadrilateral
- Defined in:
- lib/mindee/geometry/quadrilateral.rb
Overview
Contains exactly 4 relative vertices coordinates (Points).
Instance Attribute Summary collapse
- #bottom_left ⇒ Mindee::Geometry::Point
- #bottom_right ⇒ Mindee::Geometry::Point
- #top_left ⇒ Mindee::Geometry::Point
- #top_right ⇒ Mindee::Geometry::Point
Instance Method Summary collapse
- #[](key) ⇒ Mindee::Geometry::Point
-
#initialize(top_left, top_right, bottom_right, bottom_left) ⇒ Quadrilateral
constructor
A new instance of Quadrilateral.
-
#size ⇒ Object
A quadrilateral has four corners, always.
Constructor Details
#initialize(top_left, top_right, bottom_right, bottom_left) ⇒ Quadrilateral
Returns a new instance of Quadrilateral.
21 22 23 24 25 26 |
# File 'lib/mindee/geometry/quadrilateral.rb', line 21 def initialize(top_left, top_right, bottom_right, bottom_left) @top_left = top_left @top_right = top_right @bottom_right = bottom_right @bottom_left = bottom_left end |
Instance Attribute Details
#bottom_left ⇒ Mindee::Geometry::Point
15 16 17 |
# File 'lib/mindee/geometry/quadrilateral.rb', line 15 def bottom_left @bottom_left end |
#bottom_right ⇒ Mindee::Geometry::Point
13 14 15 |
# File 'lib/mindee/geometry/quadrilateral.rb', line 13 def bottom_right @bottom_right end |
#top_left ⇒ Mindee::Geometry::Point
9 10 11 |
# File 'lib/mindee/geometry/quadrilateral.rb', line 9 def top_left @top_left end |
#top_right ⇒ Mindee::Geometry::Point
11 12 13 |
# File 'lib/mindee/geometry/quadrilateral.rb', line 11 def top_right @top_right end |
Instance Method Details
#[](key) ⇒ Mindee::Geometry::Point
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mindee/geometry/quadrilateral.rb', line 29 def [](key) case key when 0 @top_left when 1 @top_right when 2 @bottom_right when 3 @bottom_left else throw '0, 1, 2, 3 only' end end |
#size ⇒ Object
A quadrilateral has four corners, always.
45 46 47 |
# File 'lib/mindee/geometry/quadrilateral.rb', line 45 def size 4 end |