Class: Autometal::Geoip

Inherits:
Object
  • Object
show all
Defined in:
lib/geoip.rb,
lib/geoip/city.rb,
lib/geoip/installer.rb,
lib/geoip/organization.rb

Defined Under Namespace

Classes: City, Installer, Organization, Package

Constant Summary collapse

VERSION =
'0.4.1'
DATA_FILE_PATH =
"/usr/local/share/GeoIP/"
BIN =
"geoiplookup"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ip_or_domain) ⇒ Geoip

Returns a new instance of Geoip.



9
10
11
12
# File 'lib/geoip.rb', line 9

def initialize ip_or_domain
  @org = Organization.new(ip_or_domain) if Organization.installed?
  @geo = City.new(ip_or_domain) if City.installed?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



14
15
16
17
# File 'lib/geoip.rb', line 14

def method_missing(m, *args, &block)
  return @org.send(m, *args, &block) if @org and @org.respond_to?(m)
  return @geo.send(m, *args, &block) if @geo and @geo.respond_to?(m)
end

Class Method Details

.bin_installed?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/geoip.rb', line 19

def self.bin_installed?
  File.exists?(%x{ which #{self::BIN} }.strip)
end