class Geonames::Data::NameIndex

Public Class Methods

load(filepath, &filter) click to toggle source
# File lib/geonames/data/name_index.rb, line 18
def self.load(filepath, &filter)
  new(Feature.load(filepath, &filter))
end
new(features) click to toggle source
# File lib/geonames/data/name_index.rb, line 4
def initialize(features)
  @index = features.inject({}) do |index, feature|
    feature.names.map(&:downcase).inject(index) do |index, name|
      index[name] ||= []
      index[name].push(feature).uniq!
      index
    end
  end
end

Public Instance Methods

[](name) click to toggle source
# File lib/geonames/data/name_index.rb, line 14
def [](name)
  @index[name.downcase]
end