Class: TZInfo::CountryInfo
- Inherits:
-
Object
- Object
- TZInfo::CountryInfo
- Defined in:
- lib/tzinfo/country_info.rb
Overview
Represents a country and references to its timezones as returned by a DataSource.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
The ISO 3166 country code.
-
#name ⇒ Object
readonly
The name of the country.
Instance Method Summary collapse
-
#initialize(code, name) ⇒ CountryInfo
constructor
Constructs a new CountryInfo with an ISO 3166 country code and name.
-
#inspect ⇒ Object
Returns internal object state as a programmer-readable string.
-
#zone_identifiers ⇒ Object
Returns a frozen array of all the zone identifiers for the country.
-
#zones ⇒ Object
Returns a frozen array of all the timezones for the for the country as CountryTimezone instances.
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
#code ⇒ Object (readonly)
The ISO 3166 country code.
28 29 30 |
# File 'lib/tzinfo/country_info.rb', line 28 def code @code end |
#name ⇒ Object (readonly)
The name of the country.
31 32 33 |
# File 'lib/tzinfo/country_info.rb', line 31 def name @name end |
Instance Method Details
#inspect ⇒ Object
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_identifiers ⇒ Object
Returns a frozen array of all the zone identifiers for the country. The identifiers are ordered by importance according to the DataSource.
46 47 48 |
# File 'lib/tzinfo/country_info.rb', line 46 def zone_identifiers raise NotImplementedError, 'Subclasses must override zone_identifiers' end |
#zones ⇒ Object
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.
54 55 56 |
# File 'lib/tzinfo/country_info.rb', line 54 def zones raise NotImplementedError, 'Subclasses must override zone_identifiers' end |