Class: TZInfo::TZDataCountry
- Inherits:
-
Object
- Object
- TZInfo::TZDataCountry
- Defined in:
- lib/tzinfo/tzdataparser.rb
Overview
An ISO 3166 country.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
:nodoc:.
-
#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.
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
#code ⇒ Object (readonly)
:nodoc:
1140 1141 1142 |
# File 'lib/tzinfo/tzdataparser.rb', line 1140 def code @code end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
1141 1142 1143 |
# File 'lib/tzinfo/tzdataparser.rb', line 1141 def name @name end |
#zones ⇒ Object (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 |