123456789_123456789_123456789_123456789_123456789_

Module: TZInfo::Format2::TimezoneDefinition::ClassMethods Private

Do not use. This module is for internal use only.
Relationships & Source Files
Defined in: lib/tzinfo/format2/timezone_definition.rb

Overview

Class methods for inclusion.

Instance Method Summary

Instance Method Details

#getTimezoneInfo

Returns:

  • (TimezoneInfo)

    the last time zone to be defined.

[ GitHub ]

  
# File 'lib/tzinfo/format2/timezone_definition.rb', line 23

def get
  @timezone
end

#linked_timezone(identifier, link_to_identifier) (private)

Defines a linked time zone.

Parameters:

  • identifier (String)

    the identifier of the time zone being defined.

  • link_to_identifier (String)

    the identifier the new time zone links to (is an alias for).

[ GitHub ]

  
# File 'lib/tzinfo/format2/timezone_definition.rb', line 64

def linked_timezone(identifier, link_to_identifier)
  # Dedupe non-frozen literals from format 1 on all Ruby versions and
  # format 2 on Ruby < 2.3 (without frozen_string_literal support).
  string_deduper = StringDeduper.global
  @timezone = DataSources::LinkedTimezoneInfo.new(string_deduper.dedupe(identifier), string_deduper.dedupe(link_to_identifier))
end

#timezone(identifier) {|definer| ... } (private)

Defines a data time zone.

Parameters:

  • identifier (String)

    the identifier of the time zone.

Yields:

  • (definer)

    yields to the caller to define the time zone.

Yield Parameters:

[ GitHub ]

  
# File 'lib/tzinfo/format2/timezone_definition.rb', line 41

def timezone(identifier)
  # Dedupe non-frozen literals from format 1 on all Ruby versions and
  # format 2 on Ruby < 2.3 (without frozen_string_literal support).
  string_deduper = StringDeduper.global
  identifier = string_deduper.dedupe(identifier)

  definer = timezone_definer_class.new(string_deduper)
  yield definer
  transitions = definer.transitions

  @timezone = if transitions.empty?
    DataSources::ConstantOffsetDataTimezoneInfo.new(identifier, definer.first_offset)
  else
    DataSources::TransitionsDataTimezoneInfo.new(identifier, transitions)
  end
end

#timezone_definer_classClass (private)

Returns:

  • (Class)

    the class to be instantiated and yielded by #timezone.

[ GitHub ]

  
# File 'lib/tzinfo/format2/timezone_definition.rb', line 31

def timezone_definer_class
  TimezoneDefiner
end