Class: Timezone::Configure

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

If you aren’t going to initialize timezone objects based on lat,lng then this configuration is not necessary.

Examples:

Timezone::Configure.begin do |c|
  c.url = 'api.geonames.org'
  c.username = 'foo-bar'
end

Class Method Summary collapse

Class Method Details

.begin {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



78
79
80
# File 'lib/timezone/configure.rb', line 78

def self.begin
  yield self
end

.default_for_listObject



91
92
93
# File 'lib/timezone/configure.rb', line 91

def self.default_for_list
  @@default_list ||= nil
end

.default_for_list=(*list) ⇒ Object



95
96
97
# File 'lib/timezone/configure.rb', line 95

def self.default_for_list=(*list)
  @@default_list = list.flatten!
end

.http_clientObject

The HTTP client that handles requests to geonames

Returns:



57
58
59
# File 'lib/timezone/configure.rb', line 57

def self.http_client
  @@http_client ||= Timezone::NetHTTPClient
end

.http_client=(client) ⇒ Object

The HTTP client that handles requests to geonames

Parameters:

  • client (Object)

    the HTTP client that handles requests to geonames



66
67
68
# File 'lib/timezone/configure.rb', line 66

def self.http_client=(client)
  @@http_client = client
end

.order_list_byObject



99
100
101
# File 'lib/timezone/configure.rb', line 99

def self.order_list_by
  @@order_by ||= :utc_offset
end

.order_list_by=(order) ⇒ Object



103
104
105
# File 'lib/timezone/configure.rb', line 103

def self.order_list_by=(order)
  @@order_by = order
end

.protocolSting

The Geonames API HTTP protocol

Returns:

  • (Sting)

    the Geonames API URL (‘api.geonames.org’)



49
50
51
# File 'lib/timezone/configure.rb', line 49

def self.protocol
  @protocol ||= 'http'
end

.protocol=(protocol) ⇒ Object

The Geonames API HTTP protocol

Parameters:

  • protocol (String)

    the Geonames API HTTP procotol



41
42
43
# File 'lib/timezone/configure.rb', line 41

def self.protocol=(protocol)
  @@protocol = protocol
end

.replace(what, with = Hash.new) ⇒ Object



82
83
84
85
# File 'lib/timezone/configure.rb', line 82

def self.replace(what, with = Hash.new)
  replacements # instantiate @@replacements
  @@replacements[what] = with[:with]
end

.replacementsObject



87
88
89
# File 'lib/timezone/configure.rb', line 87

def self.replacements
  @@replacements ||= {}
end

.urlSting

The Geonames API URL

Returns:

  • (Sting)

    the Geonames API URL (‘api.geonames.org’)



25
26
27
# File 'lib/timezone/configure.rb', line 25

def self.url
  @@url ||= 'api.geonames.org'
end

.url=(url) ⇒ Object

The Geonames API URL

Parameters:

  • url (Sting)

    the Geonames API URL



33
34
35
# File 'lib/timezone/configure.rb', line 33

def self.url=(url)
  @@url = url
end

.usernameObject



70
71
72
# File 'lib/timezone/configure.rb', line 70

def self.username
  @@username
end

.username=(username) ⇒ Object



74
75
76
# File 'lib/timezone/configure.rb', line 74

def self.username= username
  @@username = username
end