Class: Vedeu::Colours::Background Private
- Inherits:
-
Translator
- Object
- Translator
- Vedeu::Colours::Background
- Defined in:
- lib/vedeu/colours/background.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The class represents one half (the other, can be found at Foreground) of a terminal colour escape sequence.
Instance Attribute Summary
Attributes inherited from Translator
Instance Method Summary collapse
- #background? ⇒ Boolean private
-
#named ⇒ String
private
private
Returns an escape sequence for a named colour.
- #prefix ⇒ String private private
- #repository ⇒ Vedeu::Colours::Backgrounds private private
- #to_ast ⇒ String private
- #to_h ⇒ Hash<Symbol => String> (also: #to_hash) private
- #to_html(_options = {}) ⇒ String private
Methods inherited from Translator
#blue, coerce, #css_to_numbered, #css_to_rgb, #empty?, #eql?, #escape_sequence, #green, #initialize, #numbered, #numbered_prefix, #red, #register, #registered?, #retrieve, #rgb, #rgb_prefix, #validator
Methods included from Vedeu::Common
#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?
Constructor Details
This class inherits a constructor from Vedeu::Colours::Translator
Instance Method Details
#background? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 |
# File 'lib/vedeu/colours/background.rb', line 16 def background? present?(to_s) end |
#named ⇒ String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Valid names can be found at EscapeSequences::Esc#valid_codes
Returns an escape sequence for a named colour.
58 59 60 |
# File 'lib/vedeu/colours/background.rb', line 58 def named Vedeu.esc.background_colour(colour) end |
#prefix ⇒ String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 |
# File 'lib/vedeu/colours/background.rb', line 47 def prefix "\e[48;" end |
#repository ⇒ Vedeu::Colours::Backgrounds (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 |
# File 'lib/vedeu/colours/background.rb', line 63 def repository Vedeu.background_colours end |
#to_ast ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 24 25 26 |
# File 'lib/vedeu/colours/background.rb', line 21 def to_ast return '' unless background? return ':bg' unless rgb? ":bg_#{colour.to_s.slice(1..-1)}" end |
#to_h ⇒ Hash<Symbol => String> Also known as: to_hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 32 33 |
# File 'lib/vedeu/colours/background.rb', line 29 def to_h { background: colour.to_s, } end |
#to_html(_options = {}) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 |
# File 'lib/vedeu/colours/background.rb', line 38 def to_html( = {}) return '' unless rgb? "background-color:#{colour};" end |