class Markdo::ForecastCommand

Public Instance Methods

run() click to toggle source
# File lib/markdo/commands/forecast_command.rb, line 6
def run
  dates_over_the_next_week.each do |date|
    abbreviation = abbreviations_by_wday(date.wday)
    count = task_collection.due_on(date).length

    @stdout.puts("#{abbreviation}: #{count}")
  end

  due_next_week = task_collection.due_between(@today + 7,
                                              @today + 14)
  @stdout.puts("Next: #{due_next_week.length}")
end

Private Instance Methods

abbreviations_by_wday(wday) click to toggle source
# File lib/markdo/commands/forecast_command.rb, line 21
def abbreviations_by_wday(wday)
  abbrevs = {
    0 => 'Su',
    1 => 'Mo',
    2 => 'Tu',
    3 => 'We',
    4 => 'Th',
    5 => 'Fr',
    6 => 'Sa',
  }

  abbrevs[wday]
end
dates_over_the_next_week() click to toggle source
# File lib/markdo/commands/forecast_command.rb, line 37
def dates_over_the_next_week
  (2..7).to_a.map { |offset| @today + offset }
end