Sha256: 2b495f9639e08d757fe16227bf75fda1915e69d69cface7786bae96d4f6b6412

Contents?: true

Size: 683 Bytes

Versions: 9

Compression:

Stored size: 683 Bytes

Contents

# encoding: utf-8

module TTY
  class Table
    module Operation
      # A class responsible for escaping special chars in a table field
      #
      # @api private
      class Escape

        # Escape special characters in a table field
        #
        # @param [TTY::Table::Field] field
        #
        # @param [Integer] row
        #   the field row index
        #
        # @param [Integer] col
        #   the field column index
        #
        # @api public
        def call(field, row, col)
          field.content.gsub(/(\t|\r|\n)/) do |val|
            val.dump.gsub('"', '')
          end
        end
      end # Escape
    end # Operation
  end # Table
end # TTY

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tty-table-0.10.0 lib/tty/table/operation/escape.rb
tty-table-0.9.0 lib/tty/table/operation/escape.rb
tty-table-0.8.0 lib/tty/table/operation/escape.rb
tty-table-0.7.0 lib/tty/table/operation/escape.rb
tty-table-0.6.0 lib/tty/table/operation/escape.rb
tty-table-0.5.0 lib/tty/table/operation/escape.rb
tty-table-0.4.0 lib/tty/table/operation/escape.rb
tty-table-0.3.0 lib/tty/table/operation/escape.rb
tty-table-0.2.0 lib/tty/table/operation/escape.rb