Method: RubyCurses::TextView#sanitize
- Defined in:
- lib/rbcurse/core/widgets/rtextview.rb
#sanitize(content) ⇒ Object
takes a block, this way anyone extending this class can just pass a block to do his job This modifies the string
583 584 585 586 587 588 589 590 591 592 593 594 595 |
# File 'lib/rbcurse/core/widgets/rtextview.rb', line 583 def sanitize content #:nodoc: if content.is_a? String content.chomp! # trying out since gsub giving #<ArgumentError: invalid byte sequence in UTF-8> 2011-09-11 content.replace(content.encode("ASCII-8BIT", :invalid => :replace, :undef => :replace, :replace => "?")) if content.respond_to?(:encode) content.gsub!(/[\t\n\r]/, ' ') # don't display tab or newlines content.gsub!(/[^[:print:]]/, '') # don't display non print characters else content end end |