Class: Nin::Presenter::TodoPresenter

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/nin/presenters/todo_presenter.rb

Instance Method Summary collapse

Instance Method Details

#callObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/nin/presenters/todo_presenter.rb', line 4

def call
  return 'No todo items yet. Call `nin add hello world` to add a new item.' if self.empty?

  formatting_options = { separating_spaces: 4,
                         longest_id: self.map(&:id).max.length,
                         longest_date: 11 }

  self.map do |item|
    Presenter::ItemPresenter.new(item).call(formatting_options)
  end
end