Class: Chronic::RepeaterQuarter

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

Overview

:nodoc:

Direct Known Subclasses

RepeaterQuarterName

Constant Summary collapse

MONTHS_PER_QUARTER =
3
QUARTER_SECONDS =

3 * 30 * 24 * 60 * 60

7_776_000

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_quarter_names, scan_for_season_names, scan_for_times, scan_for_units

Methods inherited from Tag

#initialize, scan, #start=

Constructor Details

This class inherits a constructor from Chronic::Tag

Instance Method Details

#next(pointer) ⇒ Object



6
7
8
9
10
# File 'lib/chronic/repeaters/repeater_quarter.rb', line 6

def next(pointer)
  @current_span ||= quarter(@now)
  offset_quarter_amount = pointer == :future ? 1 : -1
  @current_span = offset_quarter(@current_span.begin, offset_quarter_amount)
end

#offset(span, amount, pointer) ⇒ Object



16
17
18
19
# File 'lib/chronic/repeaters/repeater_quarter.rb', line 16

def offset(span, amount, pointer)
  direction = pointer == :future ? 1 : -1
  offset_quarter(span.begin, amount * direction)
end

#thisObject



12
13
14
# File 'lib/chronic/repeaters/repeater_quarter.rb', line 12

def this(*)
  @current_span = quarter(@now)
end

#to_sObject



25
26
27
# File 'lib/chronic/repeaters/repeater_quarter.rb', line 25

def to_s
  super << '-quarter'
end

#widthObject



21
22
23
# File 'lib/chronic/repeaters/repeater_quarter.rb', line 21

def width
  @current_span ? @current_span.width : QUARTER_SECONDS
end