Sha256: dc302fd21ca25a359422d8acd8bdc4ff6f013745d9906d98d0e8e230bc860fdb

Contents?: true

Size: 791 Bytes

Versions: 32

Compression:

Stored size: 791 Bytes

Contents

module Chronic
  class RepeaterSecond < Repeater #:nodoc:
    SECOND_SECONDS = 1 # haha, awesome

    def initialize(type)
      super
    end

    def next(pointer = :future)
      super

      direction = pointer == :future ? 1 : -1

      if !@second_start
        @second_start = @now + (direction * SECOND_SECONDS)
      else
        @second_start += SECOND_SECONDS * direction
      end

      Span.new(@second_start, @second_start + SECOND_SECONDS)
    end

    def this(pointer = :future)
      super

      Span.new(@now, @now + 1)
    end

    def offset(span, amount, pointer)
      direction = pointer == :future ? 1 : -1
      span + direction * amount * SECOND_SECONDS
    end

    def width
      SECOND_SECONDS
    end

    def to_s
      super << '-second'
    end
  end
end

Version data entries

32 entries across 32 versions & 5 rubygems

Version Path
chronic-mmlac-0.6.4.2 lib/chronic/repeaters/repeater_second.rb
chronic-0.9.1 lib/chronic/repeaters/repeater_second.rb
chronic-0.9.0 lib/chronic/repeaters/repeater_second.rb
Hokkaido-0.1.5 chronic/lib/chronic/repeaters/repeater_second.rb
Hokkaido-0.1.4 chronic/lib/chronic/repeaters/repeater_second.rb
Hokkaido-0.1.3 chronic/lib/chronic/repeaters/repeater_second.rb
Hokkaido-0.1.2 chronic/lib/chronic/repeaters/repeater_second.rb
Hokkaido-0.1.1 chronic/lib/chronic/repeaters/repeater_second.rb
Hokkaido-0.1.0 chronic/lib/chronic/repeaters/repeater_second.rb
Hokkaido-0.0.9 chronic/lib/chronic/repeaters/repeater_second.rb
Hokkaido-0.0.6 chronic/lib/chronic/repeaters/repeater_second.rb
Hokkaido-0.0.5 chronic/lib/chronic/repeaters/repeater_second.rb
Hokkaido-0.0.4 chronic/lib/chronic/repeaters/repeater_second.rb
chronic-0.8.0 lib/chronic/repeaters/repeater_second.rb
chronic-0.7.0 lib/chronic/repeaters/repeater_second.rb
chronic_2001-0.1.5 lib/chronic/repeaters/repeater_second.rb
chronic_2001-0.1.4 lib/chronic/repeaters/repeater_second.rb
chronic_2001-0.1.3 lib/chronic/repeaters/repeater_second.rb
chronic_2001-0.1.2 lib/chronic/repeaters/repeater_second.rb
chronic_2001-0.1.1 lib/chronic/repeaters/repeater_second.rb