123456789_123456789_123456789_123456789_123456789_

Module: TZInfo::Format1::CountryIndexDefinition::ClassMethods Private

Do not use. This module is for internal use only.
Relationships & Source Files
Defined in: lib/tzinfo/format1/country_index_definition.rb

Overview

Class methods for inclusion.

Instance Method Summary

Instance Method Details

#countriesHash<String, DataSources::CountryInfo>

Returns:

  • (Hash<String, DataSources::CountryInfo>)

    a frozen Hash of all the countries that have been defined in the index keyed by their codes.

[ GitHub ]

  
# File 'lib/tzinfo/format1/country_index_definition.rb', line 29

def countries
  @description_deduper = nil
  @countries.freeze
end

#country(code, name) {|definer| ... } (private)

Defines a country with an ISO 3166-1 alpha-2 country code and name.

Parameters:

  • code (String)

    the ISO 3166-1 alpha-2 country code.

  • name (String)

    the name of the country.

Yields:

  • (definer)

    (optional) to obtain the time zones for the country.

Yield Parameters:

[ GitHub ]

  
# File 'lib/tzinfo/format1/country_index_definition.rb', line 42

def country(code, name)
  @description_deduper ||= StringDeduper.new

  zones = if block_given?
    definer = CountryDefiner.new(StringDeduper.global, @description_deduper)
    yield definer
    definer.timezones
  else
    []
  end

  @countries[code.freeze] = DataSources::CountryInfo.new(code, name, zones)
end