123456789_123456789_123456789_123456789_123456789_

Class: TZInfo::TransitionRule Abstract Private

Do not use. This class is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
TZInfo::AbsoluteDayOfYearTransitionRule, TZInfo::DayOfMonthTransitionRule, TZInfo::DayOfWeekTransitionRule, TZInfo::DayOfYearTransitionRule, TZInfo::JulianDayOfYearTransitionRule, TZInfo::LastDayOfMonthTransitionRule
Inherits: Object
Defined in: lib/tzinfo/transition_rule.rb

Overview

This class is abstract.

Base class for rules definining the transition between standard and daylight savings time.

Class Method Summary

Instance Attribute Summary

  • #transition_at ⇒ Integer readonly Internal use only

    Returns the number of seconds after midnight local time on the day identified by the rule at which the transition occurs.

Instance Method Summary

Instance Attribute Details

#transition_atInteger (readonly)

Returns the number of seconds after midnight local time on the day identified by the rule at which the transition occurs. Can be negative to denote a time on the prior day. Can be greater than or equal to 86,400 to denote a time of the following day.

Returns:

  • (Integer)

    the time in seconds after midnight local time at which the transition occurs.

[ GitHub ]

  
# File 'lib/tzinfo/transition_rule.rb', line 18

attr_reader :transition_at

Instance Method Details

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

Determines if this TransitionRule is equal to another instance.

Parameters:

  • r (Object)

    the instance to test for equality.

Returns:

  • (Boolean)

    true if r is a TransitionRule with the same #transition_at as this TransitionRule, otherwise false.

[ GitHub ]

  
# File 'lib/tzinfo/transition_rule.rb', line 47

def ==(r)
  r.kind_of?(TransitionRule) && @transition_at == r.transition_at
end

#at(offset, year) ⇒ TimestampWithOffset

Calculates the time of the transition from a given offset on a given year.

Parameters:

  • offset (TimezoneOffset)

    the current offset at the time the rule will transition.

  • year (Integer)

    the year in which the transition occurs (local time).

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/transition_rule.rb', line 37

def at(offset, year)
  day = get_day(offset, year)
  TimestampWithOffset.set_timezone_offset(Timestamp.for(day + @transition_at), offset)
end

#eql?(r)

Alias for #==.

[ GitHub ]

  
# File 'lib/tzinfo/transition_rule.rb', line 50

alias eql? ==

#hashInteger

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/transition_rule.rb', line 54

def hash
  hash_args.hash
end

#hash_argsArray (protected)

Returns:

  • (Array)

    an Array of parameters that will influence the output of #hash.

[ GitHub ]

  
# File 'lib/tzinfo/transition_rule.rb', line 62

def hash_args
  [@transition_at]
end