Class: TZInfo::TZDataZone
- Inherits:
-
TZDataDefinition
- Object
- TZDataDefinition
- TZInfo::TZDataZone
- Defined in:
- lib/tzinfo/tzdataparser.rb
Overview
A tz data Zone. Each line from the tz data is loaded as a TZDataObservance.
Instance Attribute Summary collapse
-
#observances ⇒ Object
readonly
:nodoc:.
Attributes inherited from TZDataDefinition
#name, #name_elements, #path_elements
Instance Method Summary collapse
- #add_observance(observance) ⇒ Object
-
#initialize(name) ⇒ TZDataZone
constructor
A new instance of TZDataZone.
-
#write_index_record(file) ⇒ Object
Writes an index record for this zone.
-
#write_module(output_dir) ⇒ Object
Writes the module for the zone.
Methods inherited from TZDataDefinition
Constructor Details
#initialize(name) ⇒ TZDataZone
Returns a new instance of TZDataZone.
576 577 578 579 |
# File 'lib/tzinfo/tzdataparser.rb', line 576 def initialize(name) super @observances = [] end |
Instance Attribute Details
#observances ⇒ Object (readonly)
:nodoc:
574 575 576 |
# File 'lib/tzinfo/tzdataparser.rb', line 574 def observances @observances end |
Instance Method Details
#add_observance(observance) ⇒ Object
581 582 583 |
# File 'lib/tzinfo/tzdataparser.rb', line 581 def add_observance(observance) @observances << observance end |
#write_index_record(file) ⇒ Object
Writes an index record for this zone.
604 605 606 |
# File 'lib/tzinfo/tzdataparser.rb', line 604 def write_index_record(file) file.puts(" timezone #{TZDataParser.quote_str(@name)}") end |
#write_module(output_dir) ⇒ Object
Writes the module for the zone. Iterates all the periods and asks them to write all periods in the timezone.
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
# File 'lib/tzinfo/tzdataparser.rb', line 587 def write_module(output_dir) puts "writing zone #{name}" create_file(output_dir) {|file| file.puts("timezone #{TZDataParser.quote_str(@name)} do |tz|") file.indent(2) transitions = find_transitions transitions.output_module(file) file.indent(-2) file.puts('end') } end |