Merge branch 'gem'
[fuzed.git] / helloworld / vendor / gems / chronic-0.2.2 / lib / chronic / repeaters / repeater_second.rb
blob6d05545ca56c962a7d541e03b3da5dbf847712ab
1 class Chronic::RepeaterSecond < Chronic::Repeater #:nodoc:
2   SECOND_SECONDS = 1 # haha, awesome
3   
4   def next(pointer = :future)
5     super
6     
7     direction = pointer == :future ? 1 : -1
8     
9     if !@second_start
10       @second_start = @now + (direction * SECOND_SECONDS)
11     else
12       @second_start += SECOND_SECONDS * direction
13     end
14     
15     Chronic::Span.new(@second_start, @second_start + SECOND_SECONDS)
16   end
17   
18   def this(pointer = :future)
19     super
20     
21     Chronic::Span.new(@now, @now + 1)
22   end
23   
24   def offset(span, amount, pointer)
25     direction = pointer == :future ? 1 : -1
26     span + direction * amount * SECOND_SECONDS
27   end
28   
29   def width
30     SECOND_SECONDS
31   end
32   
33   def to_s
34     super << '-second'
35   end
36 end