Sha256: 04bf9bb4c2137a3a4fc0de67937926e13383109ff62359f68e7f8dce5a4cc000
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
module Nin module Presenter class ItemPresenter < ::SimpleDelegator def call(options = {}) _id, _completed, _date, _desc, _tags = id, decorate_completed, decorate_date, decorate_desc, decorate_tags separating_spaces = options.fetch(:separating_spaces, 2) id_spaces = options.fetch(:longest_id, 1) + separating_spaces completed_spaces = _completed.length + separating_spaces date_spaces = _date.length + (options.fetch(:longest_date, 11) - _date.remove_color.length) + separating_spaces sprintf("%-#{id_spaces}d %-#{completed_spaces}s %-#{date_spaces}s %s %s", _id, _completed, _date, _desc, _tags) end private def decorate_desc if self.archived? self.desc.yellow elsif self.completed? self.desc.white else self.desc end end def decorate_completed if self.completed? '[x]'.green else '[ ]' end end def decorate_date date_in_words = '@' << self.date.humanize if self.past? date_in_words.magenta elsif self.today? date_in_words.bold.cyan else date_in_words.cyan end end def decorate_tags self.tags.map { |tag| tag.dup.prepend('#') }.join(' ').blue end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nin-1.3.0 | lib/nin/presenters/item_presenter.rb |