class TZInfo::Country

us.zone_info
us.zones
us.zone_identifiers
us = Country.get(‘US’)
For example:
An ISO 3166 country. Can be used to get a list of Timezones for a country.

def self._load(data)

Loads a marshalled Country.
def self._load(data)
  Country.get(data)
end

def self.all

Returns an Array of all the defined Countries.
def self.all
  load_index
  Indexes::Countries.countries.keys.collect {|code| get(code)}
end       

def self.all_codes

Returns an Array of all the valid country codes.
def self.all_codes
  load_index
  Indexes::Countries.countries.keys
end

def self.get(identifier)

exception if it couldn't be found.
Gets a Country by its ISO 3166 code. Raises an InvalidCountryCode
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

def self.load_index

Loads in the index of countries if it hasn't already been loaded.
def self.load_index
  unless @@index_loaded
    require 'tzinfo/indexes/countries'
    @@index_loaded = true
  end        
end     

def self.new(identifier)

otherwise calls get(identifier).
If identifier is a CountryInfo object, initializes the Country instance,
def self.new(identifier)      
  if identifier.kind_of?(CountryInfo)
    instance = super()
    instance.send :setup, identifier
    instance
  else
    get(identifier)
  end
end

def <=>(c)

than self, 0 if c is equal to self and +1 if c is greater than self.
Compare two Countries based on their code. Returns -1 if c is less
def <=>(c)
  code <=> c.code
end

def _dump(limit)

Dumps this Country for marshalling.
def _dump(limit)
  code
end

def code

The ISO 3166 country code.
def code
  @info.code
end

def eql?(c)

Country.
Returns true if and only if the code of c is equal to the code of this
def eql?(c)
  self == c
end

def hash

Returns a hash value for this Country.
def hash
  code.hash
end

def inspect

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

def name

The name of the country.
def name
  @info.name
end

def setup(info)

parameter is a CountryInfo that defines the country.
Called by Country.new to initialize a new Country instance. The info
def setup(info)
  @info = info        
end

def to_s

Alias for name.
def to_s
  name
end

def zone_identifiers

(2) puts the most populous zones first, where that does not contradict (1).
(1) makes some geographical sense, and
are in an order that
Returns a frozen array of all the zone identifiers for the country. These
def zone_identifiers
  @info.zone_identifiers
end

def zone_info

(2) puts the most populous zones first, where that does not contradict (1).
(1) makes some geographical sense, and
These are in an order that
CountryTimezone instances (containing extra information about each zone).
Returns a frozen array of all the timezones for the for the country as
def zone_info
  @info.zones
end

def zones

(2) puts the most populous zones first, where that does not contradict (1).
(1) makes some geographical sense, and
that
a conversion is actually required. The Timezones are returned in an order
objects to avoid the overhead of loading Timezone definitions until
An array of all the Timezones for this country. Returns TimezoneProxy
def zones
  zone_identifiers.collect {|id|
    Timezone.get_proxy(id)        
  }
end