Sha256: 7097812549403ecb5be369d1562a3c923bdb1a9d24521c97cf4edadb36f9bf87

Contents?: true

Size: 779 Bytes

Versions: 10

Compression:

Stored size: 779 Bytes

Contents

module Vedeu
  class Colour
    class << self
      def define(pair = [])
        return '' if pair.empty?

        new(pair).define
      end
      alias_method :set, :define

      def reset
        new.reset
      end
    end

    def initialize(pair = [])
      @pair = pair || []
    end

    def define
      [foreground, background].join
    end
    alias_method :set, :define

    def reset
      [foreground(:default), background(:default)].join
    end

    def foreground(value = pair[0])
      @foreground ||= Foreground.escape_sequence(value)
    end
    alias_method :fg, :foreground

    def background(value = pair[1])
      @background ||= Background.escape_sequence(value)
    end
    alias_method :bg, :background

    private

    attr_reader :pair
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
vedeu-0.0.24 lib/vedeu/output/colour.rb
vedeu-0.0.23 lib/vedeu/output/colour.rb
vedeu-0.0.22 lib/vedeu/output/colour.rb
vedeu-0.0.21 lib/vedeu/output/colour.rb
vedeu-0.0.20 lib/vedeu/output/colour.rb
vedeu-0.0.19 lib/vedeu/output/colour.rb
vedeu-0.0.18 lib/vedeu/output/colour.rb
vedeu-0.0.17 lib/vedeu/output/colour.rb
vedeu-0.0.16 lib/vedeu/output/colour.rb
vedeu-0.0.15 lib/vedeu/output/colour.rb