Class: TZInfo::TZDataZone

Inherits:
TZDataDefinition show all
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

Attributes inherited from TZDataDefinition

#name, #name_elements, #path_elements

Instance Method Summary collapse

Methods inherited from TZDataDefinition

#create_file

Constructor Details

#initialize(name) ⇒ TZDataZone

Returns a new instance of TZDataZone.



569
570
571
572
# File 'lib/tzinfo/tzdataparser.rb', line 569

def initialize(name)
  super
  @observances = []
end

Instance Attribute Details

#observancesObject (readonly)

:nodoc:



567
568
569
# File 'lib/tzinfo/tzdataparser.rb', line 567

def observances
  @observances
end

Instance Method Details

#add_observance(observance) ⇒ Object



574
575
576
# File 'lib/tzinfo/tzdataparser.rb', line 574

def add_observance(observance)      
  @observances << observance
end

#write_index_record(file) ⇒ Object

Writes an index record for this zone.



597
598
599
# File 'lib/tzinfo/tzdataparser.rb', line 597

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.



580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
# File 'lib/tzinfo/tzdataparser.rb', line 580

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