Class: TZInfo::DataSources::CountryInfo
- Inherits:
-
Object
- Object
- TZInfo::DataSources::CountryInfo
- Defined in:
- lib/tzinfo/data_sources/country_info.rb
Overview
Represents a country and references to its time zones as returned by a TZInfo::DataSource.
Instance Attribute Summary collapse
-
#code ⇒ String
readonly
The ISO 3166-1 alpha-2 country code.
-
#name ⇒ String
readonly
The name of the country.
-
#zones ⇒ Array<CountryTimezone>
readonly
The time zones observed in the country.
Instance Method Summary collapse
-
#initialize(code, name, zones) ⇒ CountryInfo
constructor
Initializes a new CountryInfo.
-
#inspect ⇒ String
The internal object state as a programmer-readable
String
.
Constructor Details
#initialize(code, name, zones) ⇒ CountryInfo
Initializes a new TZInfo::DataSources::CountryInfo. The passed in code
, name
and
zones
instances will be frozen.
26 27 28 29 30 31 32 33 |
# File 'lib/tzinfo/data_sources/country_info.rb', line 26 def initialize(code, name, zones) raise ArgumentError, 'code must be specified' unless code raise ArgumentError, 'name must be specified' unless name raise ArgumentError, 'zones must be specified' unless zones @code = code.freeze @name = name.freeze @zones = zones.freeze end |
Instance Attribute Details
#code ⇒ String (readonly)
Returns the ISO 3166-1 alpha-2 country code.
10 11 12 |
# File 'lib/tzinfo/data_sources/country_info.rb', line 10 def code @code end |
#name ⇒ String (readonly)
Returns the name of the country.
13 14 15 |
# File 'lib/tzinfo/data_sources/country_info.rb', line 13 def name @name end |
#zones ⇒ Array<CountryTimezone> (readonly)
Returns the time zones observed in the country.
16 17 18 |
# File 'lib/tzinfo/data_sources/country_info.rb', line 16 def zones @zones end |
Instance Method Details
#inspect ⇒ String
Returns the internal object state as a programmer-readable
String
.
37 38 39 |
# File 'lib/tzinfo/data_sources/country_info.rb', line 37 def inspect "#<#{self.class}: #@code>" end |