Class: TZInfo::Data::TZDataZone
- Inherits:
-
TZDataDefinition
- Object
- TZDataDefinition
- TZInfo::Data::TZDataZone
- Includes:
- TZDataParserUtils
- Defined in:
- lib/tzinfo/data/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
Returns the value of attribute observances.
Attributes inherited from TZDataDefinition
#name, #name_elements, #path_elements
Instance Method Summary collapse
- #add_observance(observance) ⇒ Object
-
#initialize(name, years) ⇒ 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, years) ⇒ TZDataZone
Returns a new instance of TZDataZone.
655 656 657 658 659 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 655 def initialize(name, years) super(name) @years = years @observances = [] end |
Instance Attribute Details
#observances ⇒ Object (readonly)
Returns the value of attribute observances.
653 654 655 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 653 def observances @observances end |
Instance Method Details
#add_observance(observance) ⇒ Object
661 662 663 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 661 def add_observance(observance) @observances << observance end |
#write_index_record(file) ⇒ Object
Writes an index record for this zone.
684 685 686 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 684 def write_index_record(file) file.puts(" timezone #{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.
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 667 def write_module(output_dir) puts "writing zone #{name}" create_file(output_dir) {|file| file.puts("timezone #{quote_str(@name)} do |tz|") file.indent(2) transitions = find_transitions transitions.output_module(file) file.indent(-2) file.puts('end') } end |