Class: TZInfo::Data::TZDataCountry
- Inherits:
-
Object
- Object
- TZInfo::Data::TZDataCountry
- Includes:
- TZDataParserUtils
- Defined in:
- lib/tzinfo/data/tzdataparser.rb
Overview
An ISO 3166 country.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#zones ⇒ Object
readonly
Returns the value of attribute zones.
Instance Method Summary collapse
-
#add_zone(zone) ⇒ Object
Adds a TZDataCountryTimezone.
-
#initialize(code, name) ⇒ TZDataCountry
constructor
A new instance of TZDataCountry.
- #write_index_record(file) ⇒ Object
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
#code ⇒ Object (readonly)
Returns the value of attribute code.
1241 1242 1243 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 1241 def code @code end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
1242 1243 1244 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 1242 def name @name end |
#zones ⇒ Object (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 |