Module: WorldTimeApi

Defined in:
lib/world_time_api.rb,
lib/world_time_api/error.rb,
lib/world_time_api/request.rb,
lib/world_time_api/version.rb,
lib/world_time_api/response.rb

Overview

A Ruby wrapper for the World Time API.

Defined Under Namespace

Modules: Request

Constant Summary collapse

Timezones =

Returns a list of all timezones supported by the World Time API.

Examples:

WorldTimeApi::Timezones.call
-> { Request::Call["/timezone"] }
Time =

Returns the current time for the specified timezone.

Examples:

WorldTimeApi::Time.call('Europe/London')
->(timezone) { Request::Call["/timezone/#{timezone}"] }
ClientIp =

Returns the current time for the client’s IP address, or for the specified IP address if provided.

Examples:

WorldTimeApi::ClientIp.call('127.0.0.1')
->(ip = nil) { Request::Call["/ip#{ip ? "/#{ip}" : ""}"] }
Error =

Creates an error object with the specified message.

Examples:

WorldTimeApi::Error.call('Invalid timezone')
->(message) { { error: message } }
VERSION =

The current version number of the WorldTimeApi gem.

"0.1.7"
Response =

Converts the HTTParty response object into a hash.

Examples:

WorldTimeApi::Response.call(HTTParty.get('http://worldtimeapi.org/api/timezone/Europe/London'))
->(response) { JSON.parse(response.body) }