Sha256: fe25596a5036c0e09e0fc1a366f707f20531ab40c082905f9ed3c31e2d83448e

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module Troo
  module Presenters
    class List
      include DecoratorHelpers

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

      def show
        output.render Presenters::Resource.list_view(list.board)

        output.spacer

        output.indent do
          render_list
        end
      end

      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 ||= 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/list.rb