Sha256: 4806ca094f1403d76ba0ebbc1e5e6db6b9fe4c903818a65d53c3d88d56ab9db5

Contents?: true

Size: 854 Bytes

Versions: 2

Compression:

Stored size: 854 Bytes

Contents

module Troo
  module Presenters
    class Comment
      include DecoratorHelpers

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

      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

2 entries across 2 versions & 1 rubygems

Version Path
troo-0.0.10 lib/troo/presenters/comment.rb
troo-0.0.9 lib/troo/presenters/comment.rb