Class: Eztz::Client
- Inherits:
-
Object
- Object
- Eztz::Client
- Defined in:
- lib/eztz/client.rb
Overview
The Google Time Zone API client. If you need to make requests with multiple api keys, then you’ll probably want to use this class directly. Otherwise, it will be easier to use Eztz.timezone
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
-
#initialize(api_key: Eztz.api_key) ⇒ Client
constructor
A new instance of Client.
-
#timezone(location:, timestamp: Time.now.utc.to_i, language: "en") ⇒ Eztz::TimeZoneResponse
Gets timezone information for a location on earth, as well as that location’s time offset from UTC.
Constructor Details
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
12 13 14 |
# File 'lib/eztz/client.rb', line 12 def api_key @api_key end |
Instance Method Details
#timezone(location:, timestamp: Time.now.utc.to_i, language: "en") ⇒ Eztz::TimeZoneResponse
Gets timezone information for a location on earth, as well as that location’s time offset from UTC.
36 37 38 39 40 41 |
# File 'lib/eztz/client.rb', line 36 def timezone(location:, timestamp: Time.now.utc.to_i, language: "en") uri.query = query_params(location, , language) res = Net::HTTP.get_response(uri) raise ApiError, res.body unless res.is_a?(Net::HTTPSuccess) TimeZoneResponse.new(, JSON.parse(res.body)) end |