Class: Chronic::RepeaterSecond

Inherits:
Repeater show all
Defined in:
lib/chronic/repeaters/repeater_second.rb

Overview

:nodoc:

Constant Summary collapse

SECOND_SECONDS =

haha, awesome

1

Instance Attribute Summary

Attributes inherited from Tag

#type

Instance Method Summary collapse

Methods inherited from Repeater

#<=>, scan, scan_for_day_names, scan_for_day_portions, scan_for_month_names, scan_for_season_names, scan_for_times, scan_for_units

Methods inherited from Tag

#start=

Constructor Details

#initialize(type) ⇒ RepeaterSecond

Returns a new instance of RepeaterSecond.



5
6
7
# File 'lib/chronic/repeaters/repeater_second.rb', line 5

def initialize(type)
  super
end

Instance Method Details

#next(pointer = :future) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/chronic/repeaters/repeater_second.rb', line 9

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

#offset(span, amount, pointer) ⇒ Object



29
30
31
32
# File 'lib/chronic/repeaters/repeater_second.rb', line 29

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

#this(pointer = :future) ⇒ Object



23
24
25
26
27
# File 'lib/chronic/repeaters/repeater_second.rb', line 23

def this(pointer = :future)
  super

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

#to_sObject



38
39
40
# File 'lib/chronic/repeaters/repeater_second.rb', line 38

def to_s
  super << '-second'
end

#widthObject



34
35
36
# File 'lib/chronic/repeaters/repeater_second.rb', line 34

def width
  SECOND_SECONDS
end