Sha256: 41d378e40242d35e14aada547d6744b41dc52355520b92baad7804c4017c6497
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module Vedeu class Colour attr_reader :attributes # Initialises a new Colour object which is a container terminal escape # sequences controlling the foreground and background colour of a # character or collection of characters. # # @param attributes [Hash] # @return [Colour] def initialize(attributes = {}) @attributes = defaults.merge!(attributes) end # Converts the `:foreground` attribute into a terminal escape sequence. # # @return [String] def foreground @foreground ||= Foreground.escape_sequence(attributes[:foreground]) end # Converts the `:background` attribute into a terminal escape sequence. # # @return [String] def background @background ||= Background.escape_sequence(attributes[:background]) end # Returns both or either of the converted attributes into a single escape # sequence. # # @return [String] def to_s foreground + background end private # @api private # @return [Hash] def defaults { foreground: '', background: '' } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.1.18 | lib/vedeu/models/colour.rb |