Class: IPinfo::AdapterLite
- Inherits:
-
Object
- Object
- IPinfo::AdapterLite
- Defined in:
- lib/ipinfo/adapter.rb
Constant Summary collapse
- HOST =
'https://api.ipinfo.io/lite/'
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
Instance Method Summary collapse
- #get(uri) ⇒ Object
-
#initialize(token = nil, adapter = :net_http) ⇒ AdapterLite
constructor
A new instance of AdapterLite.
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
#conn ⇒ Object (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 |