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)

Returns:
  • (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)

Returns:
  • (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)

Returns:
  • (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)

Returns:
  • (String) - a serialized representation of this {Country}.

Parameters:
  • limit (Integer) -- the maximum depth to dump - ignored.
def _dump(limit)
  code
end

def all

Returns:
  • (Array) - an `Array` containing one {Country} instance
def all
  data_source.country_codes.collect {|code| get(code)}
end

def all_codes

Returns:
  • (Array) - an `Array` containing all the valid ISO 3166-1
def all_codes
  data_source.country_codes
end

def code

Returns:
  • (String) - the ISO 3166-1 alpha-2 country code.
def code
  @info.code
end

def data_source

Returns:
  • (DataSource) - the current DataSource.
def data_source
  DataSource.get
end

def eql?(c)

Returns:
  • (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)

Raises:
  • (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

Returns:
  • (Integer) - a hash based on the {code}.
def hash
  code.hash
end

def initialize(info)

Parameters:
  • info (DataSources::CountryInfo) -- the data to base the new {Country}
def initialize(info)
  @info = info
end

def inspect

Returns:
  • (String) - the internal object state as a programmer-readable
def inspect
  "#<#{self.class}: #{@info.code}>"
end

def name

Returns:
  • (String) - the name of the country.
def name
  @info.name
end

def to_s

Returns:
  • (String) - a `String` representation of this {Country} (the name of
def to_s
  name
end

def zone_identifiers

Returns:
  • (Array) - an `Array` containing the identifier for each time
def zone_identifiers
  zone_info.map(&:identifier)
end

def zone_info

Returns:
  • (Array) - a frozen `Array` containing a
def zone_info
  @info.zones
end

def zones

Returns:
  • (Array) - an `Array` containing a {Timezone} instance for
def zones
  zone_info.map(&:timezone)
end