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

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'xml/mapping' require 'datacite/mapping/geo_location_node' module Datacite module Mapping @@ -51,35 +53,35 @@ when 1 init_from_hash(args[0]) when 4 init_from_array(args) else - fail ArgumentError, "Can't construct GeoLocationBox from arguments: #{args}" + raise ArgumentError, "Can't construct GeoLocationBox from arguments: #{args}" end end def south_latitude=(value) - fail ArgumentError, 'South latitude cannot be nil' unless value - fail ArgumentError, "#{value} is not a valid south latitude" unless value >= -90 && value <= 90 + raise ArgumentError, 'South latitude cannot be nil' unless value + raise ArgumentError, "#{value} is not a valid south latitude" unless value >= -90 && value <= 90 @south_latitude = value end def west_longitude=(value) - fail ArgumentError, 'West longitude cannot be nil' unless value - fail ArgumentError, "#{value} is not a valid west longitude" unless value >= -180 && value <= 180 + raise ArgumentError, 'West longitude cannot be nil' unless value + raise ArgumentError, "#{value} is not a valid west longitude" unless value >= -180 && value <= 180 @west_longitude = value end def north_latitude=(value) - fail ArgumentError, 'North latitude cannot be nil' unless value - fail ArgumentError, "#{value} is not a valid north latitude" unless value >= -90 && value <= 90 + raise ArgumentError, 'North latitude cannot be nil' unless value + raise ArgumentError, "#{value} is not a valid north latitude" unless value >= -90 && value <= 90 @north_latitude = value end def east_longitude=(value) - fail ArgumentError, 'East longitude cannot be nil' unless value - fail ArgumentError, "#{value} is not a valid east longitude" unless value >= -180 && value <= 180 + raise ArgumentError, 'East longitude cannot be nil' unless value + raise ArgumentError, "#{value} is not a valid east longitude" unless value >= -180 && value <= 180 @east_longitude = value end # Gets the box coordinates as a string. # @return [String] the coordinates of the box as a sequence of four numbers, in the order S W N E. @@ -92,10 +94,10 @@ # @param other [GeoLocationBox] the box to compare # @return [Fixnum, nil] the sort order (-1, 0, or 1), or nil if `other` is not a # {GeoLocationBox} def <=>(other) return nil unless other.class == self.class - [:south_latitude, :west_longitude, :north_latitude, :east_longitude].each do |c| + %i[south_latitude west_longitude north_latitude east_longitude].each do |c| order = send(c) <=> other.send(c) return order if order.nonzero? end 0 end