Module: TTYString

Defined in:
lib/tty_string.rb,
lib/tty_string/row.rb,
lib/tty_string/cell.rb,
lib/tty_string/code.rb,
lib/tty_string/style.rb,
lib/tty_string/cursor.rb,
lib/tty_string/parser.rb,
lib/tty_string/screen.rb,
lib/tty_string/version.rb,
lib/tty_string/csi_code.rb,
lib/tty_string/null_style.rb,
lib/tty_string/code_definitions.rb,
lib/tty_string/csi_code_definitions.rb

Overview

Renders a string taking into ANSI escape codes and trn etc Usage: TTYString.parse(“Thisre[KThat”) => “That”

Defined Under Namespace

Classes: CSICode, Cell, Code, Cursor, Error, NullStyle, Parser, Row, Screen, Style, UnknownCodeError

Constant Summary collapse

RENDER =
:render
RAISE =
:raise
DROP =
:drop
VERSION =
'2.0.3'

Class Method Summary collapse

Class Method Details

.parse(input_string, style: DROP, unknown: DROP) ⇒ Object

rubocop:disable Metrics/MethodLength



21
22
23
24
25
26
27
28
29
30
# File 'lib/tty_string.rb', line 21

def parse(input_string, style: DROP, unknown: DROP) # rubocop:disable Metrics/MethodLength
  unless STYLE_OPTIONS.include?(style)
    raise ArgumentError, '`style:` must be either TTYString::RENDER or TTYString::DROP (default)'
  end
  unless UNKNOWN_OPTIONS.include?(unknown)
    raise ArgumentError, '`unknown:` must be either TTYString::RAISE or TTYString::DROP (default)'
  end

  Parser.new(input_string).render(style: style, unknown: unknown)
end

.to_procObject



32
33
34
# File 'lib/tty_string.rb', line 32

def to_proc
  method(:parse).to_proc
end