Class: TZInfo::RubyCountryInfo

Inherits:
CountryInfo show all
Defined in:
lib/tzinfo/ruby_country_info.rb

Overview

Represents information about a country returned by RubyDataSource.

Defined Under Namespace

Classes: Zones

Instance Attribute Summary

Attributes inherited from CountryInfo

#code, #name

Instance Method Summary collapse

Methods inherited from CountryInfo

#inspect

Constructor Details

#initialize(code, name, &block) ⇒ RubyCountryInfo

Constructs a new CountryInfo with an ISO 3166 country code, name and block. The block will be evaluated to obtain the timezones for the country when the zones are first needed.



29
30
31
32
33
34
# File 'lib/tzinfo/ruby_country_info.rb', line 29

def initialize(code, name, &block)
  super(code, name)
  @block = block
  @zones = nil
  @zone_identifiers = nil
end

Instance Method Details

#zone_identifiersObject

Returns a frozen array of all the zone identifiers for the country. These are in the order they were added using the timezone method.



38
39
40
41
42
43
44
# File 'lib/tzinfo/ruby_country_info.rb', line 38

def zone_identifiers
  unless @zone_identifiers
    @zone_identifiers = zones.collect {|zone| zone.identifier}.freeze
  end
  
  @zone_identifiers
end

#zonesObject

Returns a frozen array of all the timezones for the for the country as CountryTimezone instances. These are in the order they were added using the timezone method.



49
50
51
52
53
54
55
56
57
58
# File 'lib/tzinfo/ruby_country_info.rb', line 49

def zones
  unless @zones
    zones = Zones.new
    @block.call(zones) if @block
    @block = nil
    @zones = zones.list.freeze
  end
  
  @zones
end