class TZInfo::Format2::CountryDefiner

:nodoc:
@private
the zones of a country to be specified.
of ‘TZInfo::Data::Indexes::Countries` by {CountryIndexDefiner} to allow
Instances of {Format2::CountryDefiner} are yielded to the format 2 version

def initialize(shared_timezones, identifier_deduper, description_deduper)

Parameters:
  • description_deduper (StringDeduper) -- a {StringDeduper} instance to
  • identifier_deduper (StringDeduper) -- a {StringDeduper} instance to
  • shared_timezones (Hash) -- a `Hash`
def initialize(shared_timezones, identifier_deduper, description_deduper)
  @shared_timezones = shared_timezones
  @identifier_deduper = identifier_deduper
  @description_deduper = description_deduper
  @timezones = []
end

def timezone(identifier_or_reference, latitude_numerator = nil,

Parameters:
  • description (String) -- an optional description for the time zone.
  • longitude_denominator (Integer) -- the denominator of the
  • longitude_numerator (Integer) -- the numerator of the longitude.
  • latitude_denominator (Integer) -- the denominator of the latitude.
  • latitude_numerator (Integer) -- the numerator of the latitude.
  • identifier (String) -- the time zone identifier.
  • reference (Symbol) -- a reference for a pre-defined shared time

Overloads:
  • timezone(identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description)
  • timezone(reference)
def timezone(identifier_or_reference, latitude_numerator = nil,
            latitude_denominator = nil, longitude_numerator = nil,
            longitude_denominator = nil, description = nil)
  if latitude_numerator
    unless latitude_denominator && longitude_numerator && longitude_denominator
      raise ArgumentError, 'Either just a reference should be supplied, or the identifier, latitude and longitude must all be specified'
    end
    # Dedupe non-frozen literals from format 1 on all Ruby versions and
    # format 2 on Ruby < 2.3 (without frozen_string_literal support).
    @timezones << CountryTimezone.new(@identifier_deduper.dedupe(identifier_or_reference),
      Rational(latitude_numerator, latitude_denominator),
      Rational(longitude_numerator, longitude_denominator), description && @description_deduper.dedupe(description))
  else
    shared_timezone = @shared_timezones[identifier_or_reference]
    raise ArgumentError, "Unknown shared timezone: #{identifier_or_reference}" unless shared_timezone
    @timezones << shared_timezone
  end
end