123456789_123456789_123456789_123456789_123456789_

Class: TZInfo::DataSources::ConstantOffsetDataTimezoneInfo

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: TZInfo::DataSources::DataTimezoneInfo
Defined in: lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb

Overview

Represents a data time zone defined by a constantly observed offset.

Class Method Summary

TimezoneInfo - Inherited

.new

Initializes a new TimezoneInfo.

Instance Attribute Summary

Instance Method Summary

DataTimezoneInfo - Inherited

#create_timezone, #period_for,
#periods_for_local

Returns an Array containing the TimezonePeriods that could be observed at the local time specified by local_timestamp.

#transitions_up_to

Returns an Array of ::TZInfo::TimezoneTransition instances representing the times where the UTC offset of the time zone changes.

#raise_not_implemented

Raises a NotImplementedError to indicate that the base class is incorrectly being used directly.

TimezoneInfo - Inherited

#create_timezone, #inspect,
#raise_not_implemented

Raises a NotImplementedError.

Constructor Details

.new(identifier, constant_offset) ⇒ ConstantOffsetDataTimezoneInfo

Initializes a new ConstantOffsetDataTimezoneInfo.

The passed in identifier instance will be frozen. A reference to the passed in ::TZInfo::TimezoneOffset will be retained.

Parameters:

  • identifier (String)

    the identifier of the time zone.

  • constant_offset (TimezoneOffset)

    the constantly observed offset.

Raises:

[ GitHub ]

  
# File 'lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb', line 19

def initialize(identifier, constant_offset)
  super(identifier)
  raise ArgumentError, 'constant_offset must be specified' unless constant_offset
  @constant_offset = constant_offset
end

Instance Attribute Details

#constant_offsetTimezoneOffset (readonly)

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb', line 9

attr_reader :constant_offset

Instance Method Details

#constant_periodTimezonePeriod (private)

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb', line 51

def constant_period
  OffsetTimezonePeriod.new(@constant_offset)
end

#period_for(timestamp) ⇒ TimezonePeriod

Parameters:

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb', line 28

def period_for(timestamp)
  constant_period
end

#periods_for_local(local_timestamp) ⇒ Array<TimezonePeriod>

Parameters:

Returns:

[ GitHub ]

  
# File 'lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb', line 35

def periods_for_local(local_timestamp)
  [constant_period]
end

#transitions_up_to(to_timestamp, from_timestamp = nil) ⇒ Array

Parameters:

  • to_timestamp (Timestamp)

    ignored.

  • from_timestamp (Timestamp) (defaults to: nil)

    ignored.

Returns:

  • (Array)

    an empty Array, since there are no transitions in time zones that observe a constant offset.

[ GitHub ]

  
# File 'lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb', line 43

def transitions_up_to(to_timestamp, from_timestamp = nil)
  []
end