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, options = {}) ⇒ RepeaterSecond

Returns a new instance of RepeaterSecond.



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

def initialize(type, options = {})
  super
  @second_start = nil
end

Instance Method Details

#next(pointer = :future) ⇒ Object



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

def next(pointer = :future)
  super

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

  unless @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



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

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

#this(pointer = :future) ⇒ Object



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

def this(pointer = :future)
  super

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

#to_sObject



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

def to_s
  super << '-second'
end

#widthObject



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

def width
  SECOND_SECONDS
end