Sha256: afc7142c160a973a5471677e7176e51c96d8adcf51c5adda964adf31a2d91dd5

Contents?: true

Size: 680 Bytes

Versions: 1

Compression:

Stored size: 680 Bytes

Contents

require 'virtus'

require 'vedeu/output/colour_translator'
require 'vedeu/support/esc'

module Vedeu
  class Background < Virtus::Attribute
    def coerce(value)
      return '' if value.nil? || value.empty?

      ["\e[48;5;", ColourTranslator.translate(value), 'm'].join
    end
  end

  class Foreground < Virtus::Attribute
    def coerce(value)
      return '' if value.nil? || value.empty?

      ["\e[38;5;", ColourTranslator.translate(value), 'm'].join
    end
  end

  class Colour
    include Virtus.model

    attribute :foreground, Foreground, default: ''
    attribute :background, Background, default: ''

    def to_s
      foreground + background
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.1.7 lib/vedeu/models/colour.rb