Method: Chronik::RepeaterSeasonName#this

Defined in:
lib/chronik/repeaters/repeater_season_name.rb

#this(pointer = :future) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/chronik/repeaters/repeater_season_name.rb', line 12

def this(pointer = :future)
  # super
  
  direction = pointer == :future ? 1 : -1

  today = Time.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(@now.to_minidate)
  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 + Chronik::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
  
  Chronik::Span.new(this_ssn_start, this_ssn_end)
end