123456789_123456789_123456789_123456789_123456789_

Class: TZInfo::DataSources::CountryInfo

Relationships & Source Files
Inherits: Object
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.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(code, name, zones) ⇒ CountryInfo

Initializes a new CountryInfo. The passed in #code, #name and #zones instances will be frozen.

Parameters:

  • code (String)

    an ISO 3166-1 alpha-2 country code.

  • name (String)

    the name of the country.

  • zones (Array<CountryTimezone>)

    the time zones observed in the country.

Raises:

[ GitHub ]

  
# 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

#codeString (readonly)

Returns:

  • (String)

    the ISO 3166-1 alpha-2 country code.

[ GitHub ]

  
# File 'lib/tzinfo/data_sources/country_info.rb', line 10

attr_reader :code

#nameString (readonly)

Returns:

  • (String)

    the name of the country.

[ GitHub ]

  
# File 'lib/tzinfo/data_sources/country_info.rb', line 13

attr_reader :name

#zonesArray<CountryTimezone> (readonly)

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/data_sources/country_info.rb', line 16

attr_reader :zones

Instance Method Details

#inspectString

Returns:

  • (String)

    the internal object state as a programmer-readable String.

[ GitHub ]

  
# File 'lib/tzinfo/data_sources/country_info.rb', line 37

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