Class: Vedeu::Colours::Foreground Private

Inherits:
Translator show all
Defined in:
lib/vedeu/colours/foreground.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 Background) of a terminal colour escape sequence.

Instance Attribute Summary

Attributes inherited from Translator

#colour

Instance Method Summary collapse

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

#foreground?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.

Returns:



16
17
18
# File 'lib/vedeu/colours/foreground.rb', line 16

def foreground?
  present?(to_s)
end

#namedString (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.

Note:

Valid names can be found at EscapeSequences::Esc#valid_codes

Returns an escape sequence for a named colour.

Returns:

  • (String)


58
59
60
# File 'lib/vedeu/colours/foreground.rb', line 58

def named
  Vedeu.esc.foreground_colour(colour)
end

#prefixString (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.

Returns:

  • (String)


47
48
49
# File 'lib/vedeu/colours/foreground.rb', line 47

def prefix
  "\e[38;"
end

#repositoryVedeu::Colours::Foregrounds (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/foreground.rb', line 63

def repository
  Vedeu.foreground_colours
end

#to_astString

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.

Returns:

  • (String)


21
22
23
24
25
26
# File 'lib/vedeu/colours/foreground.rb', line 21

def to_ast
  return ''    unless foreground?
  return ':fg' unless rgb?

  ":fg_#{colour.to_s.slice(1..-1)}"
end

#to_hHash<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.

Returns:

  • (Hash<Symbol => String>)


29
30
31
32
33
# File 'lib/vedeu/colours/foreground.rb', line 29

def to_h
  {
    foreground: 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.

Parameters:

  • _options (Hash) (defaults to: {})

    Ignored.

Returns:

  • (String)


38
39
40
41
42
# File 'lib/vedeu/colours/foreground.rb', line 38

def to_html(_options = {})
  return '' unless rgb?

  "color:#{colour};"
end