Class: TTYString

Inherits:
Object
  • Object
show all
Defined in:
lib/tty_string.rb,
lib/tty_string/code.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/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, Code, Cursor, Parser, Screen

Constant Summary collapse

VERSION =
'1.1.1'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_string, clear_style: true) ⇒ TTYString

Returns a new instance of TTYString.



18
19
20
21
# File 'lib/tty_string.rb', line 18

def initialize(input_string, clear_style: true)
  @parser = Parser.new(input_string)
  @parser.clear_style = clear_style
end

Class Method Details

.parse(input_string, clear_style: true) ⇒ Object



9
10
11
# File 'lib/tty_string.rb', line 9

def parse(input_string, clear_style: true)
  new(input_string, clear_style: clear_style).to_s
end

.to_procObject



13
14
15
# File 'lib/tty_string.rb', line 13

def to_proc
  method(:parse).to_proc
end

Instance Method Details

#to_sObject



23
24
25
# File 'lib/tty_string.rb', line 23

def to_s
  parser.render
end