Class: Ziptz
- Inherits:
-
Object
- Object
- Ziptz
- Defined in:
- lib/ziptz.rb
Constant Summary collapse
- VERSION =
'1.0.32'- TZ_INFO =
{ '0' => {name: 'APO/FPO (time zone unknown)', offset: 0}, '4' => {name: 'Atlantic', offset: -4}, '5' => {name: 'Eastern', offset: -5}, '6' => {name: 'Central', offset: -6}, '7' => {name: 'Mountain', offset: -7}, '8' => {name: 'Pacific', offset: -8}, '9' => {name: 'Alaska', offset: -9}, '10' => {name: 'Hawaii-Aleutian Islands', offset: -10}, '11' => {name: 'American Samoa', offset: -11}, '13' => {name: 'Marshall Islands', offset: 12}, '14' => {name: 'Guam', offset: 10}, '15' => {name: 'Palau', offset: 9}, '16' => {name: 'Micronesia', offset: 11} }
Instance Method Summary collapse
-
#initialize ⇒ Ziptz
constructor
A new instance of Ziptz.
- #inspect ⇒ Object
- #time_zone_name(zip) ⇒ Object
- #time_zone_offset(zip) ⇒ Object
- #zips(tz_name) ⇒ Object
Constructor Details
#initialize ⇒ Ziptz
Returns a new instance of Ziptz.
22 23 24 |
# File 'lib/ziptz.rb', line 22 def initialize @zips = load_data end |
Instance Method Details
#inspect ⇒ Object
41 42 43 |
# File 'lib/ziptz.rb', line 41 def inspect "#<#{self.class}:#{object_id}>" end |
#time_zone_name(zip) ⇒ Object
26 27 28 29 |
# File 'lib/ziptz.rb', line 26 def time_zone_name(zip) hash = time_zone_info(zip) hash && hash[:name] end |
#time_zone_offset(zip) ⇒ Object
31 32 33 34 |
# File 'lib/ziptz.rb', line 31 def time_zone_offset(zip) tz = time_zone_info(zip) tz && tz[:offset] end |
#zips(tz_name) ⇒ Object
36 37 38 39 |
# File 'lib/ziptz.rb', line 36 def zips(tz_name) tz_code = tz_name_to_code[tz_name.downcase] tz_code && zips_by_code(tz_code) end |