Class: Chronic::RepeaterSecond
- Inherits:
-
Repeater
show all
- Defined in:
- lib/chronic/repeaters/repeater_second.rb
Overview
Constant Summary
collapse
- SECOND_SECONDS =
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_times, scan_for_units
Methods inherited from Tag
#initialize, #start=
Constructor Details
This class inherits a constructor from Chronic::Tag
Instance Method Details
#next(pointer = :future) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/chronic/repeaters/repeater_second.rb', line 4
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
Chronic::Span.new(@second_start, @second_start + SECOND_SECONDS)
end
|
#offset(span, amount, pointer) ⇒ Object
24
25
26
27
|
# File 'lib/chronic/repeaters/repeater_second.rb', line 24
def offset(span, amount, pointer)
direction = pointer == :future ? 1 : -1
span + direction * amount * SECOND_SECONDS
end
|
#this(pointer = :future) ⇒ Object
18
19
20
21
22
|
# File 'lib/chronic/repeaters/repeater_second.rb', line 18
def this(pointer = :future)
super
Chronic::Span.new(@now, @now + 1)
end
|
#to_s ⇒ Object
33
34
35
|
# File 'lib/chronic/repeaters/repeater_second.rb', line 33
def to_s
super << '-second'
end
|
#width ⇒ Object
29
30
31
|
# File 'lib/chronic/repeaters/repeater_second.rb', line 29
def width
SECOND_SECONDS
end
|