Class: Hexdump::Chars Private
- Inherits:
-
Object
- Object
- Hexdump::Chars
- Defined in:
- lib/hexdump/chars.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
-
#encoding ⇒ Encoding?
readonly
private
The encoding to convert the characters to.
Instance Method Summary collapse
-
#initialize(encoding = nil) ⇒ Chars
constructor
private
Initializes the chars formatter.
-
#scrub(chars) ⇒ String
private
Formats a string of characters.
Constructor Details
#initialize(encoding = nil) ⇒ Chars
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the chars formatter.
20 21 22 |
# File 'lib/hexdump/chars.rb', line 20 def initialize(encoding=nil) @encoding = encoding end |
Instance Attribute Details
#encoding ⇒ Encoding? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The encoding to convert the characters to.
12 13 14 |
# File 'lib/hexdump/chars.rb', line 12 def encoding @encoding end |
Instance Method Details
#scrub(chars) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats a string of characters.
33 34 35 36 37 38 39 40 41 42 43 |
# 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 |