Sha256: d84a3e82d7c7312dd66412dcb1285d857faf06df0cf608c3f654dd14eae1e475

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 KB

Contents

module Troo
  module Presenters
    class Board
      include DecoratorHelpers

      class << self
        # @param  [Array]
        # @param  [Hash]
        # @return [NilClass]
        def all(boards, options = {})
          boards.map { |board| new(board, options).show }
          nil
        end
      end

      # @param  [Troo::Board]
      # @param  [Hash]
      # @return [Troo::Presenters::Board]
      def initialize(board, options = {})
        @board, @options = board, options
      end

      # @return []
      def show
        output.render Presenters::Resource.list_view(board)

        output.indent do
          if board.lists.empty?
            output.spacer do
              output.render error('No lists were found.')
            end
          else
            render_lists
          end
        end
      end

      # @return []
      def render_lists
        output.spacer

        board.lists.map do |list|
          Presenters::List.new(list, output: output).render_list
        end

        nil
      end

      private

      attr_reader :board

      def output
        @output ||= options.fetch(:output)
      end

      def options
        defaults.merge!(@options)
      end

      def defaults
        {
          output: Troo::Output.new
        }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
troo-0.0.15 lib/troo/presenters/board.rb
troo-0.0.14 lib/troo/presenters/board.rb
troo-0.0.13 lib/troo/presenters/board.rb
troo-0.0.12 lib/troo/presenters/board.rb
troo-0.0.11 lib/troo/presenters/board.rb