Class: Timezone::Configure
- Inherits:
-
Object
- Object
- Timezone::Configure
- Defined in:
- lib/timezone/configure.rb
Overview
Configuration class for the Timezone gem.
You’ll want to sign up for a geonames username at Geonames. Use the username to configure your application for latitude and longitude based timezone searches. Alternatively, you’ll want to sign up for a Google api key at / Google. Use the api key to configure your application for latitude and longitude based timezone searches.
If you aren’t going to initialize timezone objects based on lat,lng then this configuration is not necessary.
Class Method Summary collapse
- .begin {|_self| ... } ⇒ Object
- .default_for_list ⇒ Object
- .default_for_list=(*list) ⇒ Object
-
.geonames_protocol ⇒ String
The Geonames API HTTP protocol.
-
.geonames_protocol=(protocol) ⇒ Object
The Geonames API HTTP protocol.
-
.geonames_url ⇒ String
The Geonames API URL.
-
.geonames_url=(url) ⇒ Object
(also: url=)
The Geonames API URL.
-
.google_api_key ⇒ String
The Google API key.
-
.google_api_key=(api_key) ⇒ Object
Google API key.
-
.google_protocol ⇒ String
The Google API HTTP protocol.
-
.google_protocol=(protocol) ⇒ Object
The Google API HTTP protocol.
-
.google_url ⇒ String
The Google API URL.
-
.google_url=(url) ⇒ Object
The Google API URL.
-
.http_client ⇒ Object
The HTTP client that handles requests to Geonames and Google.
-
.http_client=(client) ⇒ Object
The HTTP client that handles requests to Geonames and Google.
- .order_list_by ⇒ Object
- .order_list_by=(order) ⇒ Object
-
.protocol ⇒ String
Use Google protocol if key has been set else use Geonames protocol.
- .replace(what, with = Hash.new) ⇒ Object
- .replacements ⇒ Object
-
.url ⇒ String
Use Google URL if key has been set else use Geonames URL.
-
.use_google? ⇒ Boolean
Use Google API if key has been set.
-
.username ⇒ String
The Geonames API username.
-
.username=(username) ⇒ Object
The Geonames API username.
Class Method Details
.begin {|_self| ... } ⇒ Object
166 167 168 |
# File 'lib/timezone/configure.rb', line 166 def self.begin yield self end |
.default_for_list ⇒ Object
179 180 181 |
# File 'lib/timezone/configure.rb', line 179 def self.default_for_list @@default_list ||= nil end |
.default_for_list=(*list) ⇒ Object
183 184 185 |
# File 'lib/timezone/configure.rb', line 183 def self.default_for_list=(*list) @@default_list = list.flatten! end |
.geonames_protocol ⇒ String
The Geonames API HTTP protocol
105 106 107 |
# File 'lib/timezone/configure.rb', line 105 def self.geonames_protocol @@geonames_protocol ||= 'http' end |
.geonames_protocol=(protocol) ⇒ Object
The Geonames API HTTP protocol
97 98 99 |
# File 'lib/timezone/configure.rb', line 97 def self.geonames_protocol=(protocol) @@geonames_protocol = protocol end |
.geonames_url ⇒ String
The Geonames API URL
53 54 55 |
# File 'lib/timezone/configure.rb', line 53 def self.geonames_url @@geonames_url ||= 'api.geonames.org' end |
.geonames_url=(url) ⇒ Object Also known as: url=
The Geonames API URL
61 62 63 |
# File 'lib/timezone/configure.rb', line 61 def self.geonames_url=(url) @@geonames_url = url end |
.google_api_key ⇒ String
The Google API key
30 31 32 |
# File 'lib/timezone/configure.rb', line 30 def self.google_api_key @google_api_key end |
.google_api_key=(api_key) ⇒ Object
Google API key
38 39 40 |
# File 'lib/timezone/configure.rb', line 38 def self.google_api_key=(api_key) @google_api_key = api_key end |
.google_protocol ⇒ String
The Google API HTTP protocol
121 122 123 |
# File 'lib/timezone/configure.rb', line 121 def self.google_protocol @@google_protocol ||= 'https' end |
.google_protocol=(protocol) ⇒ Object
The Google API HTTP protocol
113 114 115 |
# File 'lib/timezone/configure.rb', line 113 def self.google_protocol=(protocol) @@google_protocol = protocol end |
.google_url ⇒ String
The Google API URL
73 74 75 |
# File 'lib/timezone/configure.rb', line 73 def self.google_url @@google_url ||= 'maps.googleapis.com' end |
.google_url=(url) ⇒ Object
The Google API URL
81 82 83 |
# File 'lib/timezone/configure.rb', line 81 def self.google_url=(url) @@google_url = url end |
.http_client ⇒ Object
The HTTP client that handles requests to Geonames and Google
137 138 139 |
# File 'lib/timezone/configure.rb', line 137 def self.http_client @@http_client ||= Timezone::NetHTTPClient end |
.http_client=(client) ⇒ Object
The HTTP client that handles requests to Geonames and Google
146 147 148 |
# File 'lib/timezone/configure.rb', line 146 def self.http_client=(client) @@http_client = client end |
.order_list_by ⇒ Object
187 188 189 |
# File 'lib/timezone/configure.rb', line 187 def self.order_list_by @@order_by ||= :utc_offset end |
.order_list_by=(order) ⇒ Object
191 192 193 |
# File 'lib/timezone/configure.rb', line 191 def self.order_list_by=(order) @@order_by = order end |
.protocol ⇒ String
Use Google protocol if key has been set else use Geonames protocol
129 130 131 |
# File 'lib/timezone/configure.rb', line 129 def self.protocol use_google? ? google_protocol : geonames_protocol end |
.replace(what, with = Hash.new) ⇒ Object
170 171 172 173 |
# File 'lib/timezone/configure.rb', line 170 def self.replace(what, with = Hash.new) replacements # instantiate @@replacements @@replacements[what] = with[:with] end |
.replacements ⇒ Object
175 176 177 |
# File 'lib/timezone/configure.rb', line 175 def self.replacements @@replacements ||= {} end |
.url ⇒ String
Use Google URL if key has been set else use Geonames URL
89 90 91 |
# File 'lib/timezone/configure.rb', line 89 def self.url use_google? ? google_url : geonames_url end |
.use_google? ⇒ Boolean
Use Google API if key has been set
45 46 47 |
# File 'lib/timezone/configure.rb', line 45 def self.use_google? !!google_api_key end |
.username ⇒ String
The Geonames API username
154 155 156 |
# File 'lib/timezone/configure.rb', line 154 def self.username @@username end |
.username=(username) ⇒ Object
The Geonames API username
162 163 164 |
# File 'lib/timezone/configure.rb', line 162 def self.username=(username) @@username = username end |