Class: TZInfo::TZDataTransition

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

Overview

A transition that will be used to write the periods in a zone class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(at_utc, utc_offset, std_offset, zone_id) ⇒ TZDataTransition

Returns a new instance of TZDataTransition.



869
870
871
872
873
874
875
# File 'lib/tzinfo/tzdataparser.rb', line 869

def initialize(at_utc, utc_offset, std_offset, zone_id)
  @at_utc = at_utc
  @utc_offset = utc_offset
  @std_offset = std_offset
  @zone_id = zone_id
  @offset_name = nil
end

Instance Attribute Details

#at_utcObject (readonly)

Returns the value of attribute at_utc.



863
864
865
# File 'lib/tzinfo/tzdataparser.rb', line 863

def at_utc
  @at_utc
end

#offset_nameObject

Returns the value of attribute offset_name.



867
868
869
# File 'lib/tzinfo/tzdataparser.rb', line 867

def offset_name
  @offset_name
end

#std_offsetObject (readonly)

Returns the value of attribute std_offset.



865
866
867
# File 'lib/tzinfo/tzdataparser.rb', line 865

def std_offset
  @std_offset
end

#utc_offsetObject (readonly)

Returns the value of attribute utc_offset.



864
865
866
# File 'lib/tzinfo/tzdataparser.rb', line 864

def utc_offset
  @utc_offset
end

#zone_idObject (readonly)

Returns the value of attribute zone_id.



866
867
868
# File 'lib/tzinfo/tzdataparser.rb', line 866

def zone_id
  @zone_id
end

Instance Method Details

#<=>(transition) ⇒ Object



881
882
883
884
885
886
887
888
889
890
891
# File 'lib/tzinfo/tzdataparser.rb', line 881

def <=>(transition)
  if @at_utc == transition.at_utc
    0
  elsif @at_utc.nil?
    -1
  elsif transition.nil?
    1
  else       
    @at_utc - transition.at_utc
  end
end

#clone_with_at(at_utc) ⇒ Object



897
898
899
# File 'lib/tzinfo/tzdataparser.rb', line 897

def clone_with_at(at_utc)
  TZDataTransition.new(at_utc, @utc_offset, @std_offset, @zone_id)
end

#to_sObject



877
878
879
# File 'lib/tzinfo/tzdataparser.rb', line 877

def to_s
  "At #{at_utc} UTC switch to UTC offset #{@utc_offset} with std offset #{@std_offset}, zone id #{@zone_id}"
end

#total_offsetObject



893
894
895
# File 'lib/tzinfo/tzdataparser.rb', line 893

def total_offset
  @utc_offset + @std_offset
end

#write(file) ⇒ Object



901
902
903
904
905
# File 'lib/tzinfo/tzdataparser.rb', line 901

def write(file)        
  if @at_utc
    file.puts "tz.transition #{@at_utc.year}, #{@at_utc.mon}, :#{@offset_name}, #{datetime_constructor(@at_utc)}" 
  end        
end