Class: TZInfo::TZDataTransitions

Inherits:
Object
  • Object
show all
Defined in:
lib/tzinfo/tzdataparser.rb

Overview

Collection of TZDataTransition instances used when building a zone class.

Instance Method Summary collapse

Constructor Details

#initializeTZDataTransitions

:nodoc:



728
729
730
# File 'lib/tzinfo/tzdataparser.rb', line 728

def initialize
  @transitions = []
end

Instance Method Details

#<<(transition) ⇒ Object



732
733
734
# File 'lib/tzinfo/tzdataparser.rb', line 732

def << (transition)
  @transitions << transition
end

#output_module(file) ⇒ Object



736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
# File 'lib/tzinfo/tzdataparser.rb', line 736

def output_module(file)
  optimize
  
  # Try and end on a transition to std if one happens in the last year.
  if @transitions.length > 1 && 
      @transitions.last.std_offset != 0 &&
      @transitions[@transitions.length - 2].std_offset == 0 &&
      @transitions[@transitions.length - 2].at_utc.year == TZDataParser::MAX_YEAR
    
    transitions = @transitions[0..@transitions.length - 2]
  else
    transitions = @transitions
  end
  
  process_offsets(file)
  file.puts('')
  
  transitions.each do |t|        
    t.write(file)
  end            
end