Sha256: 6435fc8eddb572fd3a33085c7a3523f0facae82c4824fbea1d043ac8ae1e70dd
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
module Vedeu # The class represents one half (the other, can be found at # {Vedeu::Foreground}) of a terminal colour escape sequence. # # @api private class Background < Translator private # Returns an escape sequence for a named background colour. # # Valid names are: `:black`, `:red`, `:green`, `:yellow`, `:blue`, # `:magenta`, `:cyan`, `:white` and `:default`. # # @return [String] def named ["\e[", background_codes[colour], 'm'].join end # Returns an escape sequence. # # @return [String] def numbered ["\e[48;5;", css_to_numbered, 'm'].join end # Returns an escape sequence. # # @return [String] def rgb if Configuration.colour_mode == 16777216 sprintf("\e[48;2;%s;%s;%sm", *css_to_rgb) else numbered end end # Produces the background named colour escape sequence hash from the # foreground escape sequence hash. # # @return [Hash] def background_codes Esc.codes.inject({}) { |h, (k, v)| h.merge(k => v + 10) } end end # Background end # Vedeu
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.2.12 | lib/vedeu/colours/background.rb |
vedeu-0.2.11 | lib/vedeu/colours/background.rb |