Class: Timezone::NetHTTPClient

Inherits:
Object
  • Object
show all
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.

Examples:

Timezone::Configure.begin do |c|
  c.http_client = Timezone::NetHTTPClient
end

Instance Method Summary collapse

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