Sha256: 5c1cf6bb8193b8febe94f046c0f071154a22cbbcee27a2cebaf60533e28210f6

Contents?: true

Size: 1.99 KB

Versions: 9

Compression:

Stored size: 1.99 KB

Contents

require 'xml/mapping_extensions'
require 'datacite/mapping/geo_location_point'
require 'datacite/mapping/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

9 entries across 9 versions & 1 rubygems

Version Path
datacite-mapping-0.1.17.2 lib/datacite/mapping/geo_location.rb
datacite-mapping-0.1.17.1 lib/datacite/mapping/geo_location.rb
datacite-mapping-0.1.17 lib/datacite/mapping/geo_location.rb
datacite-mapping-0.1.16 lib/datacite/mapping/geo_location.rb
datacite-mapping-0.1.15 lib/datacite/mapping/geo_location.rb
datacite-mapping-0.1.14 lib/datacite/mapping/geo_location.rb
datacite-mapping-0.1.13 lib/datacite/mapping/geo_location.rb
datacite-mapping-0.1.12 lib/datacite/mapping/geo_location.rb
datacite-mapping-0.1.10 lib/datacite/mapping/geo_location.rb