class TZInfo::CountryInfo
:nodoc:
class are passed to the blocks in the index that define timezones.
Class to store the data loaded from the country index. Instances of this
def initialize(code, name, &block)
block. The block will be evaluated to obtain the timezones for the country
Constructs a new CountryInfo with an ISO 3166 country code, name and
def initialize(code, name, &block) @code = code @name = name @block = block @zones = nil @zone_identifiers = nil end
def inspect
def inspect "#<#{self.class}: #@code>" end
def timezone(identifier, latitude_numerator, latitude_denominator,
def timezone(identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description = nil) # Currently only store the identifiers. @zones << CountryTimezone.new(identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description) end
def zone_identifiers
Returns a frozen array of all the zone identifiers for the country. These
def zone_identifiers unless @zone_identifiers @zone_identifiers = zones.collect {|zone| zone.identifier} @zone_identifiers.freeze end @zone_identifiers end
def zones
CountryTimezone instances. These are in the order they were added using
Returns a frozen array of all the timezones for the for the country as
def zones unless @zones @zones = [] @block.call(self) if @block @block = nil @zones.freeze end @zones end