lib/troo/presenters/list.rb in troo-0.0.9 vs lib/troo/presenters/list.rb in troo-0.0.10

- old
+ new

@@ -6,43 +6,56 @@ def initialize(list, options = {}) @list, @options = list, options end def show - output.render list.board.title - output.render "\n" + output.render Presenters::Resource.list_view(list.board) + output.spacer + output.indent do - output.render list.title + render_list + end + end - output.indent do - if cards.empty? - output.render error('No cards were found.') + "\n" - else - print_list_with_cards + def render_list + output.render Presenters::Resource.list_view(list) + + output.indent do + if list.cards.empty? + output.spacer do + output.render error('No cards were found.') end + else + render_cards end end end + def render_cards + output.spacer do + list.cards.map do |card| + output.render Presenters::Resource.list_view(card) + end + end + end + private attr_reader :list def output - @output ||= Troo::Output.new + @output ||= options.fetch(:output) end - def print_list_with_cards - output.render "\n" - cards.each do |card| - output.render card.title - end - nil + def options + defaults.merge!(@options) end - def cards - list.cards + def defaults + { + output: Troo::Output.new + } end end end end