Class: Pomodoro::Formats::Today::Archive

Inherits:
Object
  • Object
show all
Defined in:
lib/pomodoro/formats/today/archive.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_date, end_date) ⇒ Archive


8
9
10
11
# File 'lib/pomodoro/formats/today/archive.rb', line 8

def initialize(start_date, end_date)
  @start_date, @end_date = start_date, end_date
  # TODO: Validate if start_date is smaller than end_date.
end

Instance Attribute Details

#end_dateObject (readonly)

Returns the value of attribute end_date


7
8
9
# File 'lib/pomodoro/formats/today/archive.rb', line 7

def end_date
  @end_date
end

#start_dateObject (readonly)

Returns the value of attribute start_date


7
8
9
# File 'lib/pomodoro/formats/today/archive.rb', line 7

def start_date
  @start_date
end

Instance Method Details

#daysObject


13
14
15
# File 'lib/pomodoro/formats/today/archive.rb', line 13

def days
  (@start_date..@end_date).map { |date| Day.for(date) }
end

#monthsObject


17
18
19
# File 'lib/pomodoro/formats/today/archive.rb', line 17

def months
  map_to_days((@start_date..@end_date).group_by(&:month))
end

#weeksObject


21
22
23
# File 'lib/pomodoro/formats/today/archive.rb', line 21

def weeks
  map_to_days((@start_date..@end_date).group_by(&:cweek))
end