Class: Hexdump::Theme::ANSI Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hexdump/theme/ansi.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.

Represents an ANSI control sequence.

Since:

  • 1.0.0

Constant Summary collapse

RESET =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

ANSI reset control sequence

Since:

  • 1.0.0

"\e[0m"
PARAMETERS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0

{
  reset:     RESET,

  bold:      "\e[1m",
  faint:     "\e[2m",
  italic:    "\e[3m",
  underline: "\e[4m",
  invert:    "\e[7m",
  strike:    "\e[9m",
  black:     "\e[30m",
  red:       "\e[31m",
  green:     "\e[32m",
  yellow:    "\e[33m",
  blue:      "\e[34m",
  magenta:   "\e[35m",
  cyan:      "\e[36m",
  white:     "\e[37m",

  on_black:   "\e[40m",
  on_red:     "\e[41m",
  on_green:   "\e[42m",
  on_yellow:  "\e[43m",
  on_blue:    "\e[44m",
  on_magenta: "\e[45m",
  on_cyan:    "\e[46m",
  on_white:   "\e[47m"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters) ⇒ ANSI

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.

Initializes an ANSI control sequence.

Parameters:

  • parameters (Symbol, Array<Symbol>)

    The ANSI styling parameters. See PARAMETERS.

Since:

  • 1.0.0



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/hexdump/theme/ansi.rb', line 58

def initialize(parameters)
  @parameters = parameters

  @string = String.new

  Array(parameters).each do |name|
    @string << PARAMETERS.fetch(name) do
      raise(ArgumentError,"unknown ANSI parameter: #{name}")
    end
  end
end

Instance Attribute Details

#parametersSymbol+ (readonly)

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.

The style name(s).

Returns:

  • (Symbol, Array<Symbol>)

    style

Since:

  • 1.0.0



45
46
47
# File 'lib/hexdump/theme/ansi.rb', line 45

def parameters
  @parameters
end

#stringString (readonly)

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.

The ANSI string.

Returns:

Since:

  • 1.0.0



50
51
52
# File 'lib/hexdump/theme/ansi.rb', line 50

def string
  @string
end

Instance Method Details

#to_sString Also known as: to_str

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 the ANSI string.

Returns:

Since:

  • 1.0.0



75
76
77
# File 'lib/hexdump/theme/ansi.rb', line 75

def to_s
  @string
end