Sha256: 2fafeb2deb9530c04ada525b1a83c5df13d96c8c7d80ee558b43997c064b699d

Contents?: true

Size: 969 Bytes

Versions: 5

Compression:

Stored size: 969 Bytes

Contents

module Troo
  module Presenters
    class Comment
      include DecoratorHelpers

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

      # @return []
      def show
        title

        if comments?
          all_comments
        else
          no_comments
        end
      end

      private

      attr_reader :card

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

      def all_comments
        comments.map do |comment|
          output.render comment.decorator.as_view
        end
        nil
      end

      def no_comments
        output.render error('No comments were found.')
      end

      def comments?
        comments.any?
      end

      def comments
        @comments ||= card.comments
      end

      def title
        output.render card.decorator.title + "\n"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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