Sha256: 8c7704e609f7f2d03fae36dee98e95489f981ce0f22eebbaf0fdd4b9694d5eef

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

module Troo
  class BoardDecorator
    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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.7 lib/troo/display/board_decorator.rb
troo-0.0.6 lib/troo/display/board_decorator.rb
troo-0.0.5 lib/troo/display/board_decorator.rb