Class: TZInfo::Format2::CountryDefiner
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tzinfo-2.0.5/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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#timezones ⇒ Array<CountryTimezone>
readonly
The time zones observed in the country.
Instance Method Summary collapse
-
#initialize(shared_timezones, identifier_deduper, description_deduper) ⇒ CountryDefiner
constructor
Initializes a new CountryDefiner.
- #timezone(identifier_or_reference, latitude_numerator = nil, latitude_denominator = nil, longitude_numerator = nil, longitude_denominator = nil, description = nil) ⇒ Object
Constructor Details
#initialize(shared_timezones, identifier_deduper, description_deduper) ⇒ CountryDefiner
Initializes a new TZInfo::Format2::CountryDefiner.
24 25 26 27 28 29 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/format2/country_definer.rb', line 24 def initialize(shared_timezones, identifier_deduper, description_deduper) @shared_timezones = shared_timezones @identifier_deduper = identifier_deduper @description_deduper = description_deduper @timezones = [] end |
Instance Attribute Details
#timezones ⇒ Array<CountryTimezone> (readonly)
Returns the time zones observed in the country.
13 14 15 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/format2/country_definer.rb', line 13 def timezones @timezones end |
Instance Method Details
#timezone(reference) ⇒ Object #timezone(identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tzinfo-2.0.5/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 |