Sha256: 0e2242e1717eef59d186606d638f2381f088ea888228f6d74bcd2583e737207d
Contents?: true
Size: 1.14 KB
Versions: 6
Compression:
Stored size: 1.14 KB
Contents
module Vedeu # Provides a container for terminal escape sequences controlling the # foreground and background colours of a character or collection of # characters. # # @api private class Colour attr_reader :attributes # Returns a new instance of Colour. # # @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 # @return [Hash] def defaults { foreground: '', background: '' } end end # Colour end # Vedeu
Version data entries
6 entries across 6 versions & 1 rubygems