Sha256: 51f26cb8bba8e51a2ccdb7b12a23be7300487379be0ecda0ea9ba37cff2ec8c7

Contents?: true

Size: 1.97 KB

Versions: 2

Compression:

Stored size: 1.97 KB

Contents

require 'xml/mapping_extensions'
require_relative 'geo_location_point'
require_relative 'geo_location_box'

module Datacite
  module Mapping

    # A location at which the data was gathered or about which the data is focused, in the
    # form of a latitude-longitude point, a latitude-longitude quadrangle, and/or a place name.
    #
    # *Note:* Due to a quirk of the DataCite spec, it is possible for a {GeoLocation} to be empty, with
    # none of these present.
    class GeoLocation
      include XML::Mapping

      # Initializes a new {GeoLocation}
      # @param point [GeoLocationPoint, nil] the latitude and longitude at which the data was gathered or about which the data is focused.
      # @param box [GeoLocationBox, nil] the latitude-longitude quadrangle containing the area where the data was gathered or about which the data is focused.
      # @param place [String, nil] the spatial region or named place where the data was gathered or about which the data is focused.
      def initialize(point: nil, box: nil, place: nil)
        self.point = point
        self.box = box
        self.place = place
      end

      def place=(value)
        @place = value.respond_to?(:strip) ? value.strip : value
      end

      root_element_name 'geoLocation'

      # @!attribute [rw] point
      #   @return [GeoLocationPoint, nil] the latitude and longitude at which the data was gathered or about which the data is focused.
      geo_location_point_node :point, 'geoLocationPoint', default_value: nil

      # @!attribute [rw] box
      #   @return [GeoLocationBox, nil] the latitude-longitude quadrangle containing the area where the data was gathered or about which the data is focused.
      geo_location_box_node :box, 'geoLocationBox', default_value: nil

      # @!attribute [rw] place
      #   @return [String, nil] the spatial region or named place where the data was gathered or about which the data is focused.
      text_node :place, 'geoLocationPlace', default_value: nil

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
datacite-mapping-0.1.9 lib/datacite/mapping/geo_location.rb
datacite-mapping-0.1.7 lib/datacite/mapping/geo_location.rb