| Class | TZInfo::Country |
| In: |
lib/tzinfo/country.rb
|
| Parent: | Object |
An ISO 3166 country. Can be used to get a list of Timezones for a country. For example:
us = Country.get('US')
us.zone_identifiers
us.zones
us.zone_info
Gets a Country by its ISO 3166 code. Raises an InvalidCountryCode exception if it couldn‘t be found.
# File lib/tzinfo/country.rb, line 46 def self.get(identifier) instance = @@countries[identifier] unless instance load_index info = Indexes::Countries.countries[identifier] raise InvalidCountryCode.new, 'Invalid identifier' unless info instance = Country.new(info) @@countries[identifier] = instance end instance end
Returns internal object state as a programmer-readable string.
# File lib/tzinfo/country.rb, line 100 def inspect "#<#{self.class}: #{@info.code}>" end
Returns a frozen array of all the zone identifiers for the country. These are in an order that
(1) makes some geographical sense, and (2) puts the most populous zones first, where that does not contradict (1).
# File lib/tzinfo/country.rb, line 108 def zone_identifiers @info.zone_identifiers end
Returns a frozen array of all the timezones for the for the country as CountryTimezone instances (containing extra information about each zone). These are in an order that
(1) makes some geographical sense, and (2) puts the most populous zones first, where that does not contradict (1).
# File lib/tzinfo/country.rb, line 130 def zone_info @info.zones end
An array of all the Timezones for this country. Returns TimezoneProxy objects to avoid the overhead of loading Timezone definitions until a conversion is actually required. The Timezones are returned in an order that
(1) makes some geographical sense, and (2) puts the most populous zones first, where that does not contradict (1).
# File lib/tzinfo/country.rb, line 119 def zones zone_identifiers.collect {|id| Timezone.get_proxy(id) } end