lib/troo/display/board_presenter.rb in troo-0.0.4 vs lib/troo/display/board_presenter.rb in troo-0.0.5

- old
+ new

@@ -3,12 +3,12 @@ class << self def render_all(board, options = {}) new(board, options).render_all end - def render_show(board, options = {}) - new(board, options).render_show + def show(board, options = {}) + new(board, options).show end end include DecoratorHelpers @@ -16,50 +16,56 @@ @board = board @options = options end def render_all - spacing({foot: false}) do - print BoardDecorator.new(board).short + puts board.decorator.title - if board.lists.any? - board.lists.each do |list| - indent do - print ListDecorator.new(list).short - end - end - else - print_error "No lists were found.\n" - end - end + print_error "No lists were found." if lists.empty? + + print_lists end - def render_show - spacing do - print BoardDecorator.new(board).short + def show + puts board.decorator.title - if board.lists.any? - board.lists.each do |list| - indent do - print ListDecorator.new(list).short + print_error "No lists were found." if lists.empty? - if list.cards.any? - list.cards.each do |card| - indent do - print CardDecorator.new(card).short - end - end - else - print_error "No cards were found." - end - end - end - else - print_error "No lists were found." - end - end + print_lists_with_cards end private attr_reader :board + + def print_lists_with_cards + lists.each do |list| + title_for(list) + + print_error "No cards were found." if list.cards.empty? + + list.cards(unformatted).each do |card| + title_for(card) + end + end + puts + end + + def print_lists + lists.each do |list| + title_for(list) + end + puts + end + + def lists + board.decorator.lists + end + + def unformatted + { + ansicolor: false, + colour: nil, + underline: nil + } + end end end