Class: Chronic::RepeaterSeasonName
- Inherits:
-
RepeaterSeason
- Object
- Tag
- Repeater
- RepeaterSeason
- Chronic::RepeaterSeasonName
- Defined in:
- lib/chronic/repeaters/repeater_season_name.rb
Overview
:nodoc:
Constant Summary collapse
- SEASON_SECONDS =
91 * 24 * 60 * 60
7_862_400
- DAY_SECONDS =
(24 * 60 * 60)
86_400
Constants inherited from RepeaterSeason
Chronic::RepeaterSeason::SEASONS
Instance Attribute Summary
Attributes inherited from Tag
Instance Method Summary collapse
- #next(pointer) ⇒ Object
- #offset(span, amount, pointer) ⇒ Object
- #offset_by(time, amount, pointer) ⇒ Object
- #this(pointer = :future) ⇒ Object
Methods inherited from RepeaterSeason
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, #to_s, #width
Methods inherited from Tag
Constructor Details
This class inherits a constructor from Chronic::RepeaterSeason
Instance Method Details
#next(pointer) ⇒ Object
6 7 8 9 |
# File 'lib/chronic/repeaters/repeater_season_name.rb', line 6 def next(pointer) direction = pointer == :future ? 1 : -1 find_next_season_span(direction, @type) end |
#offset(span, amount, pointer) ⇒ Object
33 34 35 |
# File 'lib/chronic/repeaters/repeater_season_name.rb', line 33 def offset(span, amount, pointer) Span.new(offset_by(span.begin, amount, pointer), offset_by(span.end, amount, pointer)) end |
#offset_by(time, amount, pointer) ⇒ Object
37 38 39 40 |
# File 'lib/chronic/repeaters/repeater_season_name.rb', line 37 def offset_by(time, amount, pointer) direction = pointer == :future ? 1 : -1 time + amount * direction * RepeaterYear::YEAR_SECONDS end |
#this(pointer = :future) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/chronic/repeaters/repeater_season_name.rb', line 11 def this(pointer = :future) direction = pointer == :future ? 1 : -1 today = Chronic.construct(@now.year, @now.month, @now.day) goal_ssn_start = today + direction * num_seconds_til_start(@type, direction) goal_ssn_end = today + direction * num_seconds_til_end(@type, direction) curr_ssn = find_current_season(MiniDate.from_time(@now)) case pointer when :past this_ssn_start = goal_ssn_start this_ssn_end = (curr_ssn == @type) ? today : goal_ssn_end when :future this_ssn_start = (curr_ssn == @type) ? today + RepeaterDay::DAY_SECONDS : goal_ssn_start this_ssn_end = goal_ssn_end when :none this_ssn_start = goal_ssn_start this_ssn_end = goal_ssn_end end construct_season(this_ssn_start, this_ssn_end) end |