Sha256: ecc209c23b0c38860ce465e163f8e19bf64809066b0adc94143898a6b6031229

Contents?: true

Size: 507 Bytes

Versions: 3

Compression:

Stored size: 507 Bytes

Contents

module TimeInterval
  class TimePair
    def self.parse(iso8601)
      halves = iso8601.split('/')

      fail ArgumentError unless halves.length == 2

      start_time, end_time = halves.map { |time| Time.parse time }

      new start_time, end_time
    end

    attr_reader :start_time
    attr_reader :end_time

    def initialize(start_time, end_time)
      @start_time = start_time
      @end_time = end_time
    end

    def iso8601
      "#{start_time.iso8601}/#{end_time.iso8601}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
time-interval-0.0.3 lib/time_interval/time_pair.rb
time-interval-0.0.2 lib/time_interval/time_pair.rb
time-interval-0.0.1 lib/time_interval/time_pair.rb