class TZInfo::Country
territorial claims.
needs. It is not intended to take or endorse any position on legal or
users, to help them select time zone data appropriate for their practical
Country information available through TZInfo is intended as an aid for
{Country} can be shared across thread boundaries.
methods of {Country} in concurrently executing threads. Instances of
The {Country} class is thread-safe. It is safe to use class and instance
united_states.zone_info
united_states.zones
united_states.zone_identifiers
united_states = Country.get(‘US’)
obtain a list of time zones observed by a country. For example:
The {Country} class represents an ISO 3166-1 country. It can be used to
def self._load(data)
-
(Country)
- the result of converting `data` back into a {Country}.
Parameters:
-
data
(String
) -- a serialized representation of a {Country}.
def self._load(data) Country.get(data) end
def <=>(c)
-
(Integer)
- -1 if `c` is less than `self`, 0 if `c` is equal to
Parameters:
-
c
(Object
) -- an `Object` to compare this {Country} with.
def <=>(c) return nil unless c.is_a?(Country) code <=> c.code end
def =~(regexp)
-
(Integer)
- the position the match starts, or `nil` if there is no
Parameters:
-
regexp
(Regexp
) -- a `Regexp` to match against the {code} of
def =~(regexp) regexp =~ code end
def _dump(limit)
-
(String)
- a serialized representation of this {Country}.
Parameters:
-
limit
(Integer
) -- the maximum depth to dump - ignored.
def _dump(limit) code end
def all
-
(Array
- an `Array` containing one {Country} instance)
def all data_source.country_codes.collect {|code| get(code)} end
def all_codes
-
(Array
- an `Array` containing all the valid ISO 3166-1)
def all_codes data_source.country_codes end
def code
-
(String)
- the ISO 3166-1 alpha-2 country code.
def code @info.code end
def data_source
-
(DataSource)
- the current DataSource.
def data_source DataSource.get end
def eql?(c)
-
(Boolean)
- `true` if `c` is an instance of {Country} and has the
Parameters:
-
c
(Object
) -- an `Object` to compare this {Country} with.
def eql?(c) self == c end
def get(code)
-
(InvalidCountryCode)
- If {code} is not a valid ISO 3166-1 alpha-2
Returns:
-
(Country)
- a {Country} instance representing the ISO-3166-1
Parameters:
-
code
(String
) -- An ISO 3166-1 alpha-2 code.
def get(code) Country.new(data_source.get_country_info(code)) end
def hash
-
(Integer)
- a hash based on the {code}.
def hash code.hash end
def initialize(info)
-
info
(DataSources::CountryInfo
) -- the data to base the new {Country}
def initialize(info) @info = info end
def inspect
-
(String)
- the internal object state as a programmer-readable
def inspect "#<#{self.class}: #{@info.code}>" end
def name
-
(String)
- the name of the country.
def name @info.name end
def to_s
-
(String)
- a `String` representation of this {Country} (the name of
def to_s name end
def zone_identifiers
-
(Array
- an `Array` containing the identifier for each time)
def zone_identifiers zone_info.map(&:identifier) end
def zone_info
-
(Array
- a frozen `Array` containing a)
def zone_info @info.zones end
def zones
-
(Array
- an `Array` containing a {Timezone} instance for)
def zones zone_info.map(&:timezone) end