Sha256: 87e14cc1432317145b3c883cf34c15b1bf5c04caf527a57670e2e303c2053398

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

module Troo
  module Presenters
    class Board
      include DecoratorHelpers

      class << self
        def all(boards, options = {})
          boards.map { |board| new(board.decorator, options).show }
          nil
        end
      end

      def initialize(board, options = {})
        @board, @options = board, options
      end

      def show
        output.render board.title

        output.indent do
          if lists.empty?
            output.render error('No lists were found.') + "\n"
          else
            print_lists_with_cards
          end
        end
      end

      private

      attr_reader :board

      def output
        @output ||= Troo::Output.new
      end

      def print_lists_with_cards
        output.render "\n"
        lists.each do |list|
          output.render list.title

          output.indent do
            if list.cards.empty?
              output.render error('No cards were found.') + "\n"
            else
              output.render "\n"
              list.cards.each do |card|
                output.render card.title
              end
              output.render "\n"
            end
          end
        end
        nil
      end

      def lists
        board.lists
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.9 lib/troo/presenters/board.rb