Sha256: d7e884d2198569fd177315221d7f9af71f92d6c3956476493d5df94e35348b81

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

require 'time_crisis/tzinfo/data_timezone_info'
require 'time_crisis/tzinfo/linked_timezone_info'

module TimeCrisis
  module TZInfo

    # TimezoneDefinition is included into Timezone definition modules.
    # TimezoneDefinition provides the methods for defining timezones.
    module TimezoneDefinition #:nodoc:
      # Add class methods to the includee.
      def self.append_features(base)
        super
        base.extend(ClassMethods)
      end

      # Class methods for inclusion.
      module ClassMethods #:nodoc:
        # Returns and yields a DataTimezoneInfo object to define a timezone.
        def timezone(identifier)
          yield @timezone = DataTimezoneInfo.new(identifier)
        end

        # Defines a linked timezone.
        def linked_timezone(identifier, link_to_identifier)
          @timezone = LinkedTimezoneInfo.new(identifier, link_to_identifier)
        end

        # Returns the last TimezoneInfo to be defined with timezone or
        # linked_timezone.
        def get
          @timezone
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
time_crisis-0.3.5 lib/time_crisis/tzinfo/timezone_definition.rb
time_crisis-0.3.2 lib/time_crisis/tzinfo/timezone_definition.rb
time_crisis-0.3.1 lib/time_crisis/tzinfo/timezone_definition.rb
time_crisis-0.3.0 lib/time_crisis/tzinfo/timezone_definition.rb
time_crisis-0.2.0 lib/time_crisis/tzinfo/timezone_definition.rb