Class: TZInfo::TransitionsTimezonePeriod

Inherits:
TimezonePeriod show all
Defined in:
lib/tzinfo/transitions_timezone_period.rb

Overview

Represents a period of time in a time zone where the same offset from UTC applies. The period of time is bounded at at least one end, either having a start transition, end transition or both start and end transitions.

Instance Attribute Summary collapse

Attributes inherited from TimezonePeriod

#offset

Instance Method Summary collapse

Methods inherited from TimezonePeriod

#abbreviation, #base_utc_offset, #dst?, #ends_at, #local_ends_at, #local_starts_at, #observed_utc_offset, #starts_at, #std_offset

Constructor Details

#initialize(start_transition, end_transition) ⇒ TransitionsTimezonePeriod

Initializes a TZInfo::TransitionsTimezonePeriod.

At least one of start_transition and end_transition must be specified.

Raises:

  • (ArgumentError)

    if both start_transition and end_transition are nil.



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/tzinfo/transitions_timezone_period.rb', line 27

def initialize(start_transition, end_transition)
  if start_transition
    super(start_transition.offset)
  elsif end_transition
    super(end_transition.previous_offset)
  else
    raise ArgumentError, 'At least one of start_transition and end_transition must be specified'
  end

  @start_transition = start_transition
  @end_transition = end_transition
end

Instance Attribute Details

#end_transitionTimezoneTransition (readonly)



15
16
17
# File 'lib/tzinfo/transitions_timezone_period.rb', line 15

def end_transition
  @end_transition
end

#start_transitionTimezoneTransition (readonly)



11
12
13
# File 'lib/tzinfo/transitions_timezone_period.rb', line 11

def start_transition
  @start_transition
end

Instance Method Details

#==(p) ⇒ Boolean Also known as: eql?

Determines if this TZInfo::TransitionsTimezonePeriod is equal to another instance.



47
48
49
# File 'lib/tzinfo/transitions_timezone_period.rb', line 47

def ==(p)
  p.kind_of?(TransitionsTimezonePeriod) && start_transition == p.start_transition && end_transition == p.end_transition
end

#hashInteger



53
54
55
# File 'lib/tzinfo/transitions_timezone_period.rb', line 53

def hash
  [@start_transition, @end_transition].hash
end

#inspectString



59
60
61
# File 'lib/tzinfo/transitions_timezone_period.rb', line 59

def inspect
  "#<#{self.class}: @start_transition=#{@start_transition.inspect}, @end_transition=#{@end_transition.inspect}>"
end