Class: TZInfo::CountryInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/tzinfo/country_info.rb

Overview

Represents a country and references to its timezones as returned by a DataSource.

Direct Known Subclasses

RubyCountryInfo, ZoneinfoCountryInfo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, name) ⇒ CountryInfo

Constructs a new CountryInfo with an ISO 3166 country code and name



34
35
36
37
# File 'lib/tzinfo/country_info.rb', line 34

def initialize(code, name)
  @code = code
  @name = name
end

Instance Attribute Details

#codeObject (readonly)

The ISO 3166 country code.



28
29
30
# File 'lib/tzinfo/country_info.rb', line 28

def code
  @code
end

#nameObject (readonly)

The name of the country.



31
32
33
# File 'lib/tzinfo/country_info.rb', line 31

def name
  @name
end

Instance Method Details

#inspectObject

Returns internal object state as a programmer-readable string.



40
41
42
# File 'lib/tzinfo/country_info.rb', line 40

def inspect
  "#<#{self.class}: #@code>"
end

#zone_identifiersObject

Returns a frozen array of all the zone identifiers for the country. The identifiers are ordered by importance according to the DataSource.

Raises:

  • (NotImplementedError)


46
47
48
# File 'lib/tzinfo/country_info.rb', line 46

def zone_identifiers
  raise NotImplementedError, 'Subclasses must override zone_identifiers'
end

#zonesObject

Returns a frozen array of all the timezones for the for the country as CountryTimezone instances.

The timezones are ordered by importance according to the DataSource.

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/tzinfo/country_info.rb', line 54

def zones
  raise NotImplementedError, 'Subclasses must override zone_identifiers'
end