Class: TTY::Table::Operation::Escape

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/table/operation/escape.rb

Overview

A class responsible for escaping special chars in a table field

Instance Method Summary collapse

Instance Method Details

#call(field, row, col) ⇒ Object

Escape special characters in a table field

Parameters:

  • field (TTY::Table::Field)
  • row (Integer)

    the field row index

  • col (Integer)

    the field column index



21
22
23
24
25
# File 'lib/tty/table/operation/escape.rb', line 21

def call(field, row, col)
  field.value = field.value.to_s.gsub(/(\t|\r|\n)/) do |val|
    val.dump.gsub('"', '')
  end
end