class Hexdump::Chars
@api private
@since 1.0.0
Attributes
encoding[R]
The encoding to convert the characters to.
@return [Encoding, nil]
Public Class Methods
new(encoding=nil)
click to toggle source
Initializes the chars formatter.
@param [Encoding, nil] encoding
The encoding to convert characters to.
# File lib/hexdump/chars.rb, line 20 def initialize(encoding=nil) @encoding = encoding end
Public Instance Methods
scrub(chars)
click to toggle source
Formats a string of characters.
@param [String] chars
The input string of raw characters.
@return [String]
The formatted string of raw characters.
# File lib/hexdump/chars.rb, line 33 def scrub(chars) if @encoding chars.force_encoding(@encoding) chars.scrub!('.') chars.gsub!(/[^[:print:]]/u,'.') else chars.tr!("^\x20-\x7e",'.') end chars end