Class: TZInfo::TZDataCountry

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

Overview

An ISO 3166 country.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, name) ⇒ TZDataCountry

Returns a new instance of TZDataCountry.



1144
1145
1146
1147
1148
# File 'lib/tzinfo/tzdataparser.rb', line 1144

def initialize(code, name)
  @code = code
  @name = name
  @zones = []
end

Instance Attribute Details

#codeObject (readonly)

:nodoc:



1140
1141
1142
# File 'lib/tzinfo/tzdataparser.rb', line 1140

def code
  @code
end

#nameObject (readonly)

Returns the value of attribute name.



1141
1142
1143
# File 'lib/tzinfo/tzdataparser.rb', line 1141

def name
  @name
end

#zonesObject (readonly)

Returns the value of attribute zones.



1142
1143
1144
# File 'lib/tzinfo/tzdataparser.rb', line 1142

def zones
  @zones
end

Instance Method Details

#add_zone(zone) ⇒ Object

Adds a TZDataCountryTimezone



1151
1152
1153
# File 'lib/tzinfo/tzdataparser.rb', line 1151

def add_zone(zone)      
  @zones << zone      
end

#write_index_record(file) ⇒ Object



1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
# File 'lib/tzinfo/tzdataparser.rb', line 1155

def write_index_record(file)
  s = "      country #{TZDataParser.quote_str(@code)}, #{TZDataParser.quote_str(@name)}"      
  s << ' do |c|' if @zones.length > 0
  
  file.puts s
  
  @zones.each do |zone|
    file.puts "        c.timezone #{TZDataParser.quote_str(zone.timezone.name)}, #{zone.location.latitude.numerator}, #{zone.location.latitude.denominator}, #{zone.location.longitude.numerator}, #{zone.location.longitude.denominator}#{zone.description.nil? ? '' : ', ' + TZDataParser.quote_str(zone.description)}" 
  end
  
  file.puts '      end' if @zones.length > 0
end