lib/datacite/mapping/geo_location_polygon.rb in datacite-mapping-0.2.5 vs lib/datacite/mapping/geo_location_polygon.rb in datacite-mapping-0.3.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'xml/mapping' module Datacite module Mapping class GeoLocationPolygon @@ -12,10 +14,10 @@ # Per the spec, the array should contain at least four points, the first and last being # identical to close the polygon. def initialize(points:) # TODO: allow simple array of point args, array of hashes self.points = points warn "Polygon should contain at least 4 points, but has #{points.size}" if points.size < 4 - warn "Polygon is not closed; last and first point should be identical, but were: [#{points[0]}], [#{points[-1]}]" if points.size > 1 unless points[0] == points[-1] + warn "Polygon is not closed; last and first point should be identical, but were: [#{points[0]}], [#{points[-1]}]" unless points[0] == points[-1] || points.size <= 1 end def points=(value) @points = value || [] end