Sha256: f150e56170cdf7e00f66b4a9a8cb019ff6308bda9ae76e88f1148077992cd38c

Contents?: true

Size: 816 Bytes

Versions: 7

Compression:

Stored size: 816 Bytes

Contents

module GeoNamesAPI
  # Arrays of Geoname instances are returned by `Hierarchy.find`
  class AlternateNames

    def initialize(alternate_names_array)
      @name_by_lang = {}
      alternate_names_array.each do |hash|
        @name_by_lang[hash['lang']] = hash['name']
      end
    end

    def [](lang)
      @name_by_lang[lang]
    end
  end
end

=begin
Expected input:
[
  {
    "name": "els Abruços",
    "lang": "ca"
  },
  {
    "name": "Abruzzen",
    "lang": "de"
  },
  {
    "name": "Abruzzo",
    "lang": "en"
  },
  {
    "name": "Los Abruzos",
    "lang": "es"
  },
  {
    "name": "Abruzzes",
    "lang": "fr"
  },
  {
    "name": "Abruzzo",
    "lang": "it"
  },
  {
    "name": "http://en.wikipedia.org/wiki/Abruzzo",
    "lang": "link"
  },
  {
    "name": "Abruzzen",
    "lang": "nl"
  }
]
=end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
geonames_api-0.1.6 lib/geonames_api/alternate_names.rb
geonames_api-0.1.5 lib/geonames_api/alternate_names.rb
geonames_api-0.1.4 lib/geonames_api/alternate_names.rb
geonames_api-0.1.3 lib/geonames_api/alternate_names.rb
geonames_api-0.1.2 lib/geonames_api/alternate_names.rb
geonames_api-0.1.1 lib/geonames_api/alternate_names.rb
geonames_api-0.1.0 lib/geonames_api/alternate_names.rb