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.



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

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

Instance Attribute Details

#codeObject (readonly)

:nodoc:



1147
1148
1149
# File 'lib/tzinfo/tzdataparser.rb', line 1147

def code
  @code
end

#nameObject (readonly)

Returns the value of attribute name.



1148
1149
1150
# File 'lib/tzinfo/tzdataparser.rb', line 1148

def name
  @name
end

#zonesObject (readonly)

Returns the value of attribute zones.



1149
1150
1151
# File 'lib/tzinfo/tzdataparser.rb', line 1149

def zones
  @zones
end

Instance Method Details

#add_zone(zone) ⇒ Object

Adds a TZDataCountryTimezone



1158
1159
1160
# File 'lib/tzinfo/tzdataparser.rb', line 1158

def add_zone(zone)      
  @zones << zone      
end

#write_index_record(file) ⇒ Object



1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
# File 'lib/tzinfo/tzdataparser.rb', line 1162

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