Sha256: e3105de649f3bcf697498cf7d57a1920257e5d137fafe15e4f889e5d147c31d3

Contents?: true

Size: 956 Bytes

Versions: 3

Compression:

Stored size: 956 Bytes

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

    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.4 lib/troo/display/board_decorator.rb
troo-0.0.3 lib/troo/display/board_decorator.rb
troo-0.0.2 lib/troo/display/board_decorator.rb