Module: Timezone
- Defined in:
- lib/timezone.rb,
lib/timezone/zone.rb,
lib/timezone/error.rb,
lib/timezone/loader.rb,
lib/timezone/lookup.rb,
lib/timezone/parser.rb,
lib/timezone/version.rb,
lib/timezone/nil_zone.rb,
lib/timezone/configure.rb,
lib/timezone/deprecate.rb,
lib/timezone/lookup/test.rb,
lib/timezone/lookup/basic.rb,
lib/timezone/lookup/google.rb,
lib/timezone/active_support.rb,
lib/timezone/lookup/geonames.rb,
lib/timezone/net_http_client.rb
Overview
rubocop:disable Style/Documentation
Defined Under Namespace
Modules: Deprecate, Error, Lookup Classes: ActiveSupport, Configure, NilZone, Zone
Constant Summary collapse
- VERSION =
The current gem version.
'0.99.1'.freeze
Class Method Summary collapse
-
.[](name) ⇒ Timezone::Zone, Timezone::NilZone
Retrieve a timezone by name.
-
.fetch(name, default = :__block) {|name| ... } ⇒ Timezone::Zone, Object
Fetch a timezone by name.
-
.lookup(lat, long, default = :__block) {|name| ... } ⇒ Timezone::Zone, Object
Lookup a timezone name by (lat, long) and then fetch the timezone object.
-
.names ⇒ Array<String>
A list of all timezone names.
Class Method Details
.[](name) ⇒ Timezone::Zone, Timezone::NilZone
Retrieve a timezone by name.
21 22 23 |
# File 'lib/timezone.rb', line 21 def self.[](name) fetch(name) { ::Timezone::NilZone.new } end |
.fetch(name, default = :__block) {|name| ... } ⇒ Timezone::Zone, Object
Fetch a timezone by name.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/timezone.rb', line 40 def self.fetch(name, default = :__block, &block) return ::Timezone::Zone.new(name) if Loader.valid?(name) if block_given? && default != :__block warn('warning: block supersedes default value argument'.freeze) end return block.call(name) if block_given? return default unless default == :__block raise ::Timezone::Error::InvalidZone end |
.lookup(lat, long, default = :__block) {|name| ... } ⇒ Timezone::Zone, Object
Lookup a timezone name by (lat, long) and then fetch the timezone object.
74 75 76 |
# File 'lib/timezone.rb', line 74 def self.lookup(lat, long, default = :__block, &block) fetch(::Timezone::Lookup.lookup.lookup(lat, long), default, &block) end |
.names ⇒ Array<String>
A list of all timezone names.
11 12 13 |
# File 'lib/timezone.rb', line 11 def self.names Loader.names end |