lib/parse/mods.rb
# returns a hash with :latitude and :longitude
returns a hash with :latitude and :longitude
returns a hash with : latitude and : longitude
def coordinates
    coords = mods.subject.cartographics.coordinates.map(&:text)
    result = Hash.new { |h, k| h[k] = [] }
    coords.each_with_object(result) do |coord, obj|
      (latitude, longitude) = coord.split(/,\s*/)
      obj[:latitude] << latitude
      obj[:longitude] << longitude
    end
  end
def coordinates coords = mods . subject . cartographics . coordinates . map ( & :text ) result = Hash . new { | h , k | h [ k ] = [ ] } coords . each_with_object ( result ) do | coord , obj | ( latitude , longitude ) = coord . split ( / , \s * / ) obj [ :latitude ] << latitude obj [ :longitude ] << longitude end end
returns a hash with :latitude and :longitude
returns a hash with : latitude and : longitude
# a hash where any value defaults to an empty array