Class: IPinfo::AdapterLite

Inherits:
Object
  • Object
show all
Defined in:
lib/ipinfo/adapter.rb

Constant Summary collapse

HOST =
'https://api.ipinfo.io/lite/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token = nil, adapter = :net_http) ⇒ AdapterLite



61
62
63
64
# File 'lib/ipinfo/adapter.rb', line 61

def initialize(token = nil, adapter = :net_http)
    @token = token
    @conn = connection(adapter)
end

Instance Attribute Details

#connObject (readonly)

Returns the value of attribute conn.



59
60
61
# File 'lib/ipinfo/adapter.rb', line 59

def conn
  @conn
end

Instance Method Details

#get(uri) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/ipinfo/adapter.rb', line 66

def get(uri)
    @conn.get(HOST + uri) do |req|
        default_headers.each_pair do |key, value|
            req.headers[key] = value
        end
        req.params['token'] = CGI.escape(token) if token
    end
end