Module: Geoip2

Defined in:
lib/geoip2.rb,
lib/geoip2/client.rb,
lib/geoip2/version.rb,
lib/geoip2/api/city.rb,
lib/geoip2/api/omni.rb,
lib/geoip2/api/country.rb,
lib/geoip2/api/insights.rb,
lib/geoip2/api/city_isp_org.rb

Defined Under Namespace

Modules: Api Classes: Client

Constant Summary collapse

VERSION =
'0.0.3'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.base_pathString

Returns the base path on the host to the api.

Returns:

  • (String)

    the base path on the host to the api



12
13
14
# File 'lib/geoip2.rb', line 12

def base_path
  @base_path
end

.hostString

Returns the host of MaxMind that you would like to work with.

Returns:

  • (String)

    the host of MaxMind that you would like to work with



8
9
10
# File 'lib/geoip2.rb', line 8

def host
  @host
end

.license_keyString

Returns the license key that is used to authenticate with MaxMind.

Returns:

  • (String)

    the license key that is used to authenticate with MaxMind



24
25
26
# File 'lib/geoip2.rb', line 24

def license_key
  @license_key
end

.parallel_requestsInteger String

Returns defines the maximum parallel request for the gem to preform.

Returns:

  • (Integer String)

    defines the maximum parallel request for the gem to preform



16
17
18
# File 'lib/geoip2.rb', line 16

def parallel_requests
  @parallel_requests
end

.user_idString

Returns the user id that is used to authenticate with MaxMind.

Returns:

  • (String)

    the user id that is used to authenticate with MaxMind



20
21
22
# File 'lib/geoip2.rb', line 20

def user_id
  @user_id
end

Class Method Details

.clientObject

Returns an instance of Geoip2::Client.

Returns:

  • an instance of Geoip2::Client



46
47
48
49
50
51
52
53
54
# File 'lib/geoip2.rb', line 46

def client
  @client ||= Geoip2::Client.new({
      host: self.host || 'geoip.maxmind.com',
      base_path: self.base_path || '/geoip/v2.1',
      parallel_requests: self.parallel_requests || 5,
      user_id: self.user_id,
      license_key: self.license_key
                                })
end

.configure {|self| ... } ⇒ Object

Configuration interface of the gem

Yields:

  • (self)

    to accept configuration settings



29
30
31
32
# File 'lib/geoip2.rb', line 29

def configure
  yield self
  true
end

.respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Makes sure that the method missing is checked with the Geoip2::Client instance

Parameters:

  • method_name (String)

    the name of the method we want to run

  • include_private (Boolean) (defaults to: false)

    defines wether to check for private functions as well

Returns:

  • (Boolean)


39
40
41
# File 'lib/geoip2.rb', line 39

def respond_to_missing?(method_name, include_private=false)
  client.respond_to?(method_name, include_private)
end