123456789_123456789_123456789_123456789_123456789_

Class: TZInfo::DayOfYearTransitionRule Abstract Private

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: TZInfo::TransitionRule
Defined in: lib/tzinfo/transition_rule.rb

Overview

This class is abstract.

A base class for transition rules that activate based on an integer day of the year.

Class Method Summary

TransitionRule - Inherited

.new

Initializes a new TransitionRule.

Instance Attribute Summary

TransitionRule - Inherited

#transition_at

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

Instance Method Summary

TransitionRule - Inherited

#==

Determines if this TransitionRule is equal to another instance.

#at

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

#eql?
#hash, #hash_args

Constructor Details

.new(day, transition_at) ⇒ DayOfYearTransitionRule

Initializes a new DayOfYearTransitionRule.

Parameters:

  • day (Integer) —

    the day of the year on which the transition occurs. The precise meaning is defined by subclasses.

  • transition_at (Integer) —

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

Raises:

  • (ArgumentError) —

    if transition_at is not an Integer.

  • (ArgumentError) —

    if day is not an Integer.

[ GitHub ]

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

def initialize(day, transition_at)
  super(transition_at)
  raise ArgumentError, 'Invalid day' unless day.kind_of?(Integer)
  @seconds = day * 86400
end

Instance Attribute Details

#seconds ⇒ Integer (readonly, protected)

Returns:

  • (Integer) —

    the day multipled by the number of seconds in a day.

[ GitHub ]

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

attr_reader :seconds

Instance Method Details

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

Determines if this DayOfYearTransitionRule is equal to another instance.

Parameters:

  • r (Object) —

    the instance to test for equality.

Returns:

  • (Boolean) —

    true if r is a DayOfYearTransitionRule with the same transition_at and day as this DayOfYearTransitionRule, otherwise false.

[ GitHub ]

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

def ==(r)
  super(r) && r.kind_of?(DayOfYearTransitionRule) && @seconds == r.seconds
end

#eql?(r)

Alias for #==.

[ GitHub ]

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

alias eql? ==

#hash_args ⇒ Array (protected)

Returns:

  • (Array) —

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

[ GitHub ]

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

def hash_args
  [@seconds] + super
end