Sha256: 7709f329cd28bd6946f644f11b59deaf7ba73af98e6a8b98aa68269b283f3a29

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

module Troo
  class BoardPresenter
    class << self
      def render_all(board, options = {})
        new(board, options).render_all
      end

      def render_show(board, options = {})
        new(board, options).render_show
      end
    end

    include DecoratorHelpers

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

    def render_all
      spacing({foot: false}) do
        print BoardDecorator.new(board).short

        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
    end

    def render_show
      spacing do
        print BoardDecorator.new(board).short

        if board.lists.any?
          board.lists.each do |list|
            indent do
              print ListDecorator.new(list).short

              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
    end

    private
    attr_reader :board
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.4 lib/troo/display/board_presenter.rb
troo-0.0.3 lib/troo/display/board_presenter.rb
troo-0.0.2 lib/troo/display/board_presenter.rb