Class: Ziptz

Inherits:
Object
  • Object
show all
Defined in:
lib/ziptz.rb

Constant Summary collapse

VERSION =
'3.0.11'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instanceObject


7
8
9
# File 'lib/ziptz.rb', line 7

def self.instance
  @instance ||= new
end

Instance Method Details

#inspectObject


37
38
39
# File 'lib/ziptz.rb', line 37

def inspect
  "#<#{self.class}:#{object_id}>"
end

#time_zone_name(zip) ⇒ Object


11
12
13
14
15
16
# File 'lib/ziptz.rb', line 11

def time_zone_name(zip)
  tz_info = time_zone_info(zip)
  return unless tz_info

  tz_info[:tz]
end

#time_zone_offset(zip) ⇒ Object


18
19
20
21
22
23
24
# File 'lib/ziptz.rb', line 18

def time_zone_offset(zip)
  tz_info = time_zone_info(zip)
  return unless tz_info

  tzm_info = tzm[tz_info[:tz]]
  tzm_info[:offset] && tzm_info[:offset].to_i
end

#time_zone_uses_dst?(zip) ⇒ Boolean

Returns:

  • (Boolean)

26
27
28
29
30
31
# File 'lib/ziptz.rb', line 26

def time_zone_uses_dst?(zip)
  tz_info = time_zone_info(zip)
  return unless tz_info

  tz_info[:dst]
end

#zips(tz_name) ⇒ Object


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

def zips(tz_name)
  tz.select { |_, v| v[:tz].downcase == tz_name.downcase }.keys
end