Class: TZInfo::Data::TZDataCountry

Inherits:
Object
  • Object
show all
Includes:
TZDataParserUtils
Defined in:
lib/tzinfo/data/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.



1245
1246
1247
1248
1249
# File 'lib/tzinfo/data/tzdataparser.rb', line 1245

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

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



1241
1242
1243
# File 'lib/tzinfo/data/tzdataparser.rb', line 1241

def code
  @code
end

#nameObject (readonly)

Returns the value of attribute name.



1242
1243
1244
# File 'lib/tzinfo/data/tzdataparser.rb', line 1242

def name
  @name
end

#zonesObject (readonly)

Returns the value of attribute zones.



1243
1244
1245
# File 'lib/tzinfo/data/tzdataparser.rb', line 1243

def zones
  @zones
end

Instance Method Details

#add_zone(zone) ⇒ Object

Adds a TZDataCountryTimezone



1252
1253
1254
# File 'lib/tzinfo/data/tzdataparser.rb', line 1252

def add_zone(zone)      
  @zones << zone      
end

#write_index_record(file) ⇒ Object



1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
# File 'lib/tzinfo/data/tzdataparser.rb', line 1256

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