Class: TZInfo::Format2::CountryIndexDefiner Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/tzinfo/format2/country_index_definer.rb |
Overview
Instances of CountryIndexDefiner
are yielded to the format 2
version of TZInfo::Data::Indexes::Countries
by CountryIndexDefinition
to allow countries and their time zones to be specified.
Class Method Summary
-
.new(identifier_deduper, description_deduper) ⇒ CountryIndexDefiner
constructor
Internal use only
Initializes a new
CountryIndexDefiner
.
Instance Attribute Summary
- #countries ⇒ Hash<String, CountryInfo> readonly Internal use only
Instance Method Summary
-
#country(code, name) {|definer| ... }
Internal use only
Defines a country.
-
#timezone(reference, identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description = nil)
Internal use only
Defines a time zone shared by many countries with an reference for subsequent use in country definitions.
Instance Attribute Details
#countries ⇒ Hash
<String
, CountryInfo
> (readonly)
# File 'lib/tzinfo/format2/country_index_definer.rb', line 13
attr_reader :countries
Instance Method Details
#country(code, name) {|definer| ... }
Defines a country.
# File 'lib/tzinfo/format2/country_index_definer.rb', line 56
def country(code, name) timezones = if block_given? definer = CountryDefiner.new(@shared_timezones, @identifier_deduper, @description_deduper) yield definer definer.timezones else [] end @countries[code.freeze] = DataSources::CountryInfo.new(code, name, timezones) end
#timezone(reference, identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description = nil)
Defines a time zone shared by many countries with an reference for
subsequent use in country definitions. The latitude and longitude are
given as the numerator and denominator of a Rational
.
# File 'lib/tzinfo/format2/country_index_definer.rb', line 39
def timezone(reference, identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description = nil) # Dedupe non-frozen literals from format 1 on all Ruby versions and # format 2 on Ruby < 2.3 (without frozen_string_literal support). @shared_timezones[reference] = CountryTimezone.new(@identifier_deduper.dedupe(identifier), Rational(latitude_numerator, latitude_denominator), Rational(longitude_numerator, longitude_denominator), description && @description_deduper.dedupe(description)) end