Module: Autometal::Geolocatable

Defined in:
lib/geoip/geolocatable.rb

Instance Method Summary collapse

Instance Method Details

#cityObject



29
# File 'lib/geoip/geolocatable.rb', line 29

def city; geoip_city.city if geoip_city; end

#countryObject



25
# File 'lib/geoip/geolocatable.rb', line 25

def country; geoip_city.country if geoip_city; end

#countyObject



27
# File 'lib/geoip/geolocatable.rb', line 27

def county; geoip_city.county if geoip_city; end

#geo_attrObject



18
19
20
21
22
23
24
# File 'lib/geoip/geolocatable.rb', line 18

def geo_attr
  begin
    send(:ip)
  rescue NoMethodError
    send(:domain)
  end
end

#geoip_cityObject



3
4
5
6
7
8
9
# File 'lib/geoip/geolocatable.rb', line 3

def geoip_city
  @geoip_city = false unless @geoip_city
  if Autometal::Geoip::City.installed?
    @geoip_city = Autometal::Geoip::City.new(geo_attr) unless @geoip_city
  end
  @geoip_city
end

#geoip_orgObject



10
11
12
13
14
15
16
# File 'lib/geoip/geolocatable.rb', line 10

def geoip_org
  @geoip_org = false unless @geoip_org
  if Autometal::Geoip::Organization.installed?
    @geoip_org = Autometal::Geoip::Organization.new(geo_attr) unless @geoip_org
  end
  @geoip_org
end

#latObject



31
# File 'lib/geoip/geolocatable.rb', line 31

def lat; geoip_city.lat if geoip_city; end

#latlngObject Also known as: latlon



37
# File 'lib/geoip/geolocatable.rb', line 37

def latlng; geoip_city.latlng if geoip_city; end

#lngObject



33
# File 'lib/geoip/geolocatable.rb', line 33

def lng; geoip_city.lng if geoip_city; end

#organizationObject



35
# File 'lib/geoip/geolocatable.rb', line 35

def organization; geoip_org.organization if geoip_org; end