Class: TZInfo::Format2::CountryDefiner Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
TZInfo::Format1::CountryDefiner
|
|
Inherits: | Object |
Defined in: | lib/tzinfo/format2/country_definer.rb |
Overview
Instances of CountryDefiner
are yielded to the format 2 version
of TZInfo::Data::Indexes::Countries
by CountryIndexDefiner
to allow
the zones of a country to be specified.
Class Method Summary
-
.new(shared_timezones, identifier_deduper, description_deduper) ⇒ CountryDefiner
constructor
Internal use only
Initializes a new
CountryDefiner
.
Instance Attribute Summary
- #timezones ⇒ Array<CountryTimezone> readonly Internal use only
Instance Method Summary
- #timezone(reference) Internal use only
Instance Attribute Details
#timezones ⇒ Array
<CountryTimezone> (readonly)
# File 'lib/tzinfo/format2/country_definer.rb', line 13
attr_reader :timezones
Instance Method Details
#timezone(reference)
#timezone(identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description)
# File 'lib/tzinfo/format2/country_definer.rb', line 46
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