Sha256: 089d4ef201e8701fc23e40d2e0301407bd496a7b1f863c6b6f7708c511436c27

Contents?: true

Size: 581 Bytes

Versions: 4

Compression:

Stored size: 581 Bytes

Contents

require 'virtus'

require 'vedeu/support/esc'

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

      Esc.background_colour(value)
    end
  end

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

      Esc.foreground_colour(value)
    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

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.1.6 lib/vedeu/models/colour.rb
vedeu-0.1.5 lib/vedeu/models/colour.rb
vedeu-0.1.4 lib/vedeu/models/colour.rb
vedeu-0.1.3 lib/vedeu/models/colour.rb