Sha256: 738227db396225ff4b4c1f1afcca6459ac134ba444c4ca78cad0d927b37cd101

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

module Troo
  module Presenters
    class Board
      include DecoratorHelpers

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

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

      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

      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

1 entries across 1 versions & 1 rubygems

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