Class: TZInfo::TransitionRule
- Inherits:
-
Object
- Object
- TZInfo::TransitionRule
- Defined in:
- lib/tzinfo/transition_rule.rb
Overview
Base class for rules definining the transition between standard and daylight savings time.
Instance Attribute Summary collapse
-
#transition_at ⇒ Object
readonly
Returns the number of seconds after midnight local time on the day identified by the rule at which the transition occurs.
Instance Method Summary collapse
-
#==(r) ⇒ Object
(also: #eql?)
Determines if this TransitionRule is equal to another instance.
-
#at(offset, year) ⇒ Object
Calculates the UTC time of the transition from a given offset on a given year.
-
#hash ⇒ Object
Returns a hash based on hash_args (defaulting to transition_at).
-
#initialize(transition_at) ⇒ TransitionRule
constructor
Initializes a new TransitionRule.
Constructor Details
#initialize(transition_at) ⇒ TransitionRule
Initializes a new TransitionRule.
14 15 16 17 |
# File 'lib/tzinfo/transition_rule.rb', line 14 def initialize(transition_at) raise ArgumentError, 'Invalid transition_at' unless transition_at.kind_of?(Integer) @transition_at = transition_at end |
Instance Attribute Details
#transition_at ⇒ Object (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.
11 12 13 |
# File 'lib/tzinfo/transition_rule.rb', line 11 def transition_at @transition_at end |
Instance Method Details
#==(r) ⇒ Object Also known as: eql?
Determines if this TransitionRule is equal to another instance.
27 28 29 |
# File 'lib/tzinfo/transition_rule.rb', line 27 def ==(r) r.kind_of?(TransitionRule) && @transition_at == r.transition_at end |
#at(offset, year) ⇒ Object
Calculates the UTC time of the transition from a given offset on a given year.
21 22 23 24 |
# File 'lib/tzinfo/transition_rule.rb', line 21 def at(offset, year) day = get_day(year) day.add_with_convert(@transition_at - offset.utc_total_offset) end |
#hash ⇒ Object
Returns a hash based on hash_args (defaulting to transition_at).
33 34 35 |
# File 'lib/tzinfo/transition_rule.rb', line 33 def hash hash_args.hash end |