Class: Chronic::RepeaterDayName
- Inherits:
-
Repeater
show all
- Defined in:
- lib/chronic/repeaters/repeater_day_name.rb
Overview
Constant Summary
collapse
- DAY_SECONDS =
86400
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
5
6
7
|
# File 'lib/chronic/repeaters/repeater_day_name.rb', line 5
def initialize(type)
super
end
|
Instance Method Details
#next(pointer) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/chronic/repeaters/repeater_day_name.rb', line 9
def next(pointer)
super
direction = pointer == :future ? 1 : -1
if !@current_date
@current_date = Date.new(@now.year, @now.month, @now.day)
@current_date += direction
day_num = symbol_to_number(@type)
while @current_date.wday != day_num
@current_date += direction
end
else
@current_date += direction * 7
end
next_date = @current_date.succ
Span.new(Chronic.construct(@current_date.year, @current_date.month, @current_date.day), Chronic.construct(next_date.year, next_date.month, next_date.day))
end
|
#this(pointer = :future) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/chronic/repeaters/repeater_day_name.rb', line 30
def this(pointer = :future)
super
pointer = :future if pointer == :none
self.next(pointer)
end
|
#to_s ⇒ Object
41
42
43
|
# File 'lib/chronic/repeaters/repeater_day_name.rb', line 41
def to_s
super << '-dayname-' << @type.to_s
end
|
#width ⇒ Object
37
38
39
|
# File 'lib/chronic/repeaters/repeater_day_name.rb', line 37
def width
DAY_SECONDS
end
|