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
Loads a marshalled Country.
# File lib/tzinfo/country.rb, line 157 157: def self._load(data) 158: Country.get(data) 159: end
Returns an Array of all the defined Countries.
# File lib/tzinfo/country.rb, line 79 79: def self.all 80: load_index 81: Indexes::Countries.countries.keys.collect {|code| get(code)} 82: end
Returns an Array of all the valid country codes.
# File lib/tzinfo/country.rb, line 73 73: def self.all_codes 74: load_index 75: Indexes::Countries.countries.keys 76: end
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 46: def self.get(identifier) 47: instance = @@countries[identifier] 48: 49: unless instance 50: load_index 51: info = Indexes::Countries.countries[identifier] 52: raise InvalidCountryCode.new, 'Invalid identifier' unless info 53: instance = Country.new(info) 54: @@countries[identifier] = instance 55: end 56: 57: instance 58: end
If identifier is a CountryInfo object, initializes the Country instance, otherwise calls get(identifier).
# File lib/tzinfo/country.rb, line 62 62: def self.new(identifier) 63: if identifier.kind_of?(CountryInfo) 64: instance = super() 65: instance.send :setup, identifier 66: instance 67: else 68: get(identifier) 69: end 70: end
Compare two Countries based on their code. Returns -1 if c is less than self, 0 if c is equal to self and +1 if c is greater than self.
# File lib/tzinfo/country.rb, line 136 136: def <=>(c) 137: code <=> c.code 138: end
Dumps this Country for marshalling.
# File lib/tzinfo/country.rb, line 152 152: def _dump(limit) 153: code 154: end
The ISO 3166 country code.
# File lib/tzinfo/country.rb, line 85 85: def code 86: @info.code 87: end
Returns true if and only if the code of c is equal to the code of this Country.
# File lib/tzinfo/country.rb, line 142 142: def eql?(c) 143: self == c 144: end
Returns a hash value for this Country.
# File lib/tzinfo/country.rb, line 147 147: def hash 148: code.hash 149: end
Returns internal object state as a programmer-readable string.
# File lib/tzinfo/country.rb, line 100 100: def inspect 101: "#<#{self.class}: #{@info.code}>" 102: end
The name of the country.
# File lib/tzinfo/country.rb, line 90 90: def name 91: @info.name 92: end
Alias for name.
# File lib/tzinfo/country.rb, line 95 95: def to_s 96: name 97: 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 108: def zone_identifiers 109: @info.zone_identifiers 110: 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 130: def zone_info 131: @info.zones 132: 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 119: def zones 120: zone_identifiers.collect {|id| 121: Timezone.get_proxy(id) 122: } 123: end
Called by Country.new to initialize a new Country instance. The info parameter is a CountryInfo that defines the country.
# File lib/tzinfo/country.rb, line 172 172: def setup(info) 173: @info = info 174: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.