123456789_123456789_123456789_123456789_123456789_

Class: TZInfo::DayOfWeekTransitionRule 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 rules that transition on a particular day of week of a given week (subclasses specify which week of the month).

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(month, day_of_week, transition_at) ⇒ DayOfWeekTransitionRule

Initializes a new DayOfWeekTransitionRule.

Parameters:

  • month (Integer) —

    the month of the year when the transition occurs.

  • day_of_week (Integer) —

    the day of the week when the transition occurs. 0 is Sunday, 6 is Saturday.

  • 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 #month is not an Integer.

  • (ArgumentError) —

    if #month is less than 1 or greater than 12.

  • (ArgumentError) —

    if #day_of_week is not an Integer.

  • (ArgumentError) —

    if #day_of_week is less than 0 or greater than 6.

[ GitHub ]

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

def initialize(month, day_of_week, transition_at)
  super(transition_at)
  raise ArgumentError, 'Invalid month' unless month.kind_of?(Integer) && month >= 1 && month <= 12
  raise ArgumentError, 'Invalid day_of_week' unless day_of_week.kind_of?(Integer) && day_of_week >= 0 && day_of_week <= 6
  @month = month
  @day_of_week = day_of_week
end

Instance Attribute Details

#day_of_week ⇒ Integer (readonly, protected)

Returns:

  • (Integer) —

    the day of the week (0 to 6 for Sunday to Monday).

[ GitHub ]

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

attr_reader :day_of_week

#is_always_first_day_of_year? ⇒ Boolean (readonly)

Returns:

  • (Boolean) —

    false.

[ GitHub ]

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

def is_always_first_day_of_year?
  false
end

#is_always_last_day_of_year? ⇒ Boolean (readonly)

Returns:

  • (Boolean) —

    false.

[ GitHub ]

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

def is_always_last_day_of_year?
  false
end

#month ⇒ Integer (readonly, protected)

Returns:

  • (Integer) —

    the month of the year (1 to 12).

[ GitHub ]

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

attr_reader :month

Instance Method Details

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

Determines if this DayOfWeekTransitionRule is equal to another instance.

Parameters:

  • r (Object) —

    the instance to test for equality.

Returns:

  • (Boolean) —

    true if r is a DayOfWeekTransitionRule with the same transition_at, month and day of week as this DayOfWeekTransitionRule, otherwise false.

[ GitHub ]

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

def ==(r)
  super(r) && r.kind_of?(DayOfWeekTransitionRule) && @month == r.month && @day_of_week == r.day_of_week
end

#eql?(r)

Alias for #==.

[ GitHub ]

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

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 313

def hash_args
  [@month, @day_of_week] + super
end