Class: Geocoder::Result::MaxmindLocal

Inherits:
Base
  • Object
show all
Defined in:
lib/geocoder/results/maxmind_local.rb

Instance Attribute Summary

Attributes inherited from Base

#cache_hit, #data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #latitude, #longitude, #province, #province_code

Constructor Details

This class inherits a constructor from Geocoder::Result::Base

Class Method Details

.response_attributesObject


39
40
41
# File 'lib/geocoder/results/maxmind_local.rb', line 39

def self.response_attributes
  %w[ip]
end

Instance Method Details

#address(format = :full) ⇒ Object


6
7
8
9
# File 'lib/geocoder/results/maxmind_local.rb', line 6

def address(format = :full)
  s = state.to_s == "" ? "" : ", #{state}"
  "#{city}#{s} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
end

#cityObject


15
16
17
# File 'lib/geocoder/results/maxmind_local.rb', line 15

def city
  @data[:city_name]
end

#coordinatesObject


11
12
13
# File 'lib/geocoder/results/maxmind_local.rb', line 11

def coordinates
  [@data[:latitude], @data[:longitude]]
end

#countryObject


27
28
29
# File 'lib/geocoder/results/maxmind_local.rb', line 27

def country
  @data[:country_name]
end

#country_codeObject


31
32
33
# File 'lib/geocoder/results/maxmind_local.rb', line 31

def country_code
  @data[:country_code2]
end

#postal_codeObject


35
36
37
# File 'lib/geocoder/results/maxmind_local.rb', line 35

def postal_code
  @data[:postal_code]
end

#stateObject


19
20
21
# File 'lib/geocoder/results/maxmind_local.rb', line 19

def state
  @data[:region_name]
end

#state_codeObject


23
24
25
# File 'lib/geocoder/results/maxmind_local.rb', line 23

def state_code
  "" # Not available in Maxmind's database
end