class MaxMind::GeoIP2::Record::Place

Location data common to different location types.

Public Class Methods

new(record, locales) click to toggle source

@!visibility private

Calls superclass method MaxMind::GeoIP2::Record::Abstract::new
# File lib/maxmind/geoip2/record/place.rb, line 11
def initialize(record, locales)
  super(record)
  @locales = locales
end

Public Instance Methods

name() click to toggle source

The first available localized name in order of preference.

@return [String, nil]

# File lib/maxmind/geoip2/record/place.rb, line 19
def name
  n = names
  return nil if n.nil?

  @locales.each do |locale|
    return n[locale] if n.key?(locale)
  end

  nil
end