Class: TZInfo::Data::TZDataTransition
- Inherits:
-
Object
- Object
- TZInfo::Data::TZDataTransition
- Includes:
- Comparable
- Defined in:
- lib/tzinfo/data/tzdataparser.rb
Overview
A transition that will be used to write the periods in a zone class.
Constant Summary collapse
- EPOCH =
DateTime.new(1970, 1, 1)
Instance Attribute Summary collapse
-
#at_utc ⇒ Object
readonly
Returns the value of attribute at_utc.
-
#offset_name ⇒ Object
Returns the value of attribute offset_name.
-
#std_offset ⇒ Object
readonly
Returns the value of attribute std_offset.
-
#utc_offset ⇒ Object
readonly
Returns the value of attribute utc_offset.
-
#zone_id ⇒ Object
readonly
Returns the value of attribute zone_id.
Instance Method Summary collapse
- #<=>(transition) ⇒ Object
- #clone_with_at(at_utc) ⇒ Object
-
#initialize(at_utc, utc_offset, std_offset, zone_id) ⇒ TZDataTransition
constructor
A new instance of TZDataTransition.
- #to_s ⇒ Object
- #total_offset ⇒ Object
- #write(file) ⇒ Object
Constructor Details
#initialize(at_utc, utc_offset, std_offset, zone_id) ⇒ TZDataTransition
Returns a new instance of TZDataTransition.
955 956 957 958 959 960 961 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 955 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_utc ⇒ Object (readonly)
Returns the value of attribute at_utc.
949 950 951 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 949 def at_utc @at_utc end |
#offset_name ⇒ Object
Returns the value of attribute offset_name.
953 954 955 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 953 def offset_name @offset_name end |
#std_offset ⇒ Object (readonly)
Returns the value of attribute std_offset.
951 952 953 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 951 def std_offset @std_offset end |
#utc_offset ⇒ Object (readonly)
Returns the value of attribute utc_offset.
950 951 952 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 950 def utc_offset @utc_offset end |
#zone_id ⇒ Object (readonly)
Returns the value of attribute zone_id.
952 953 954 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 952 def zone_id @zone_id end |
Instance Method Details
#<=>(transition) ⇒ Object
967 968 969 970 971 972 973 974 975 976 977 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 967 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
983 984 985 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 983 def clone_with_at(at_utc) TZDataTransition.new(at_utc, @utc_offset, @std_offset, @zone_id) end |
#to_s ⇒ Object
963 964 965 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 963 def to_s "At #{at_utc} UTC switch to UTC offset #{@utc_offset} with std offset #{@std_offset}, zone id #{@zone_id}" end |
#total_offset ⇒ Object
979 980 981 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 979 def total_offset @utc_offset + @std_offset end |
#write(file) ⇒ Object
987 988 989 990 991 |
# File 'lib/tzinfo/data/tzdataparser.rb', line 987 def write(file) if @at_utc file.puts "tz.transition #{@at_utc.year}, #{@at_utc.mon}, :#{@offset_name}, #{(@at_utc)}" end end |