Class: Timezone::NetHTTPClient
- Inherits:
-
Object
- Object
- Timezone::NetHTTPClient
- Defined in:
- lib/timezone/net_http_client.rb
Overview
A basic HTTP Client that handles requests to Geonames. You can create your own version of this class if you want to use a proxy or a different http library such as faraday.
Instance Method Summary collapse
- #get(url) ⇒ Object
-
#initialize(protocol, host) ⇒ NetHTTPClient
constructor
A new instance of NetHTTPClient.
Constructor Details
#initialize(protocol, host) ⇒ NetHTTPClient
Returns a new instance of NetHTTPClient.
14 15 16 17 |
# File 'lib/timezone/net_http_client.rb', line 14 def initialize(protocol, host) uri = URI.parse("#{protocol}://#{host}") @http = Net::HTTP.new(uri.host, uri.port) end |
Instance Method Details
#get(url) ⇒ Object
19 20 21 |
# File 'lib/timezone/net_http_client.rb', line 19 def get(url) @http.request(Net::HTTP::Get.new(url)) end |