Class: SimplePolygons::Polygon
- Inherits:
-
Object
- Object
- SimplePolygons::Polygon
- Defined in:
- lib/simple-polygons.rb
Overview
Basic polygon class.
Instance Method Summary collapse
-
#initialize(point_array = []) ⇒ Polygon
constructor
point_array should be an array of Location objects.
-
#number_of_points ⇒ Object
Returns the number of points.
Constructor Details
#initialize(point_array = []) ⇒ Polygon
point_array should be an array of Location objects.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/simple-polygons.rb', line 24 def initialize(point_array=[]) pts_found = [] point_array.each() do |p| if pts_found.include?(p) raise EquivalentLocationsError.new("Multiple locations of the same place found in SimplePolygons::Polygon#initialize") end pts_found << p end @points = point_array end |
Instance Method Details
#number_of_points ⇒ Object
Returns the number of points.
37 38 39 |
# File 'lib/simple-polygons.rb', line 37 def number_of_points() return @points.length() end |