Class: TZInfo::TransitionRule Abstract Private
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
Base class for rules definining the transition between standard and daylight savings time.
Class Method Summary
-
.new(transition_at) ⇒ TransitionRule
constructor
Internal use only
Initializes a new
TransitionRule
.
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
-
#==(r) ⇒ Boolean
(also: #eql?)
Internal use only
Determines if this
TransitionRule
is equal to another instance. -
#at(offset, year) ⇒ TimestampWithOffset
Internal use only
Calculates the time of the transition from a given offset on a given year.
-
#eql?(r)
Alias for #==.
- #hash ⇒ Integer Internal use only
- #hash_args ⇒ Array protected Internal use only
Instance Attribute Details
#transition_at ⇒ Integer
(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.
# 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.
# 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.
# 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 #==.
# File 'lib/tzinfo/transition_rule.rb', line 50
alias eql? ==
#hash ⇒ Integer
# File 'lib/tzinfo/transition_rule.rb', line 54
def hash hash_args.hash end
#hash_args ⇒ Array
(protected)
# File 'lib/tzinfo/transition_rule.rb', line 62
def hash_args [@transition_at] end