Sha256: af3020a4b77249f89bb3907f46a958fb2ab21de4e00721bb99678ea836ae69ca

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

module Troo
  module Decorators
    class Board
      include DecoratorHelpers

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

      def short
        [default_str, id_str, name_str].join + "\n"
      end

      def name_str
        highlight(name, options)
      end

      def default_str
        default.center(3)
      end

      def id_str
        highlight(brackets(id) + ' ', options).rjust(6)
      end

      def description
        return 'N/A' if board.description.nil? ||
                        board.description.empty?
        word_wrap(board.description)
      end

      def name
        (board.name && board.name.chomp) || 'N/A'
      end

      def default
        board.default? ? '*' : ''
      end

      def id
        board.id.to_s
      end

      def lists(alt_options = {})
        board.lists.map { |list| list.decorator(alt_options) }
      end

      private

      attr_reader :board

      def options
        defaults.merge!(@options)
      end

      def defaults
        {
          ansicolor: true,
          colour:    Esc.blue,
          underline: Esc.underline
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.8 lib/troo/decorators/board.rb