Sha256: 36e5ec9382367baab84a82436e83dff4580994afcdb32148c5a4b34dbd9d6e5b

Contents?: true

Size: 1016 Bytes

Versions: 1

Compression:

Stored size: 1016 Bytes

Contents

module Troo
  module Decorators
    class List
      include DecoratorHelpers

      def initialize(list, options = {})
        @list = list
        @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 name
        (list.name && list.name.chomp) || 'N/A'
      end

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

      def id
        list.id.to_s
      end

      def cards(alt_options = {})
        list.cards.map { |card| card.decorator(alt_options) }
      end

      private

      attr_reader :list

      def options
        defaults.merge!(@options)
      end

      def defaults
        {
          ansicolor: true,
          colour:    Esc.green,
          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/list.rb