Class: Coder::Cleaner::Simple
- Inherits:
-
Object
- Object
- Coder::Cleaner::Simple
- Defined in:
- lib/coder/cleaner/simple.rb,
lib/coder/cleaner/simple/encodings.rb,
lib/coder/cleaner/simple/byte_buffer.rb
Defined Under Namespace
Modules: Encodings Classes: ByteBuffer
Class Method Summary collapse
Instance Method Summary collapse
- #clean(str) ⇒ Object
-
#initialize(encoding) ⇒ Simple
constructor
A new instance of Simple.
Constructor Details
#initialize(encoding) ⇒ Simple
Returns a new instance of Simple.
12 13 14 15 16 |
# File 'lib/coder/cleaner/simple.rb', line 12 def initialize(encoding) const_name = encoding.to_s.upcase.gsub('-', '_') raise Coder::InvalidEncoding, "unknown encoding name - #{encoding}" unless Encodings.const_defined? const_name @encoding, @name = Encodings.const_get(const_name), encoding end |
Class Method Details
.available? ⇒ Boolean
8 9 10 |
# File 'lib/coder/cleaner/simple.rb', line 8 def self.available? true end |
Instance Method Details
#clean(str) ⇒ Object
18 19 20 21 22 |
# File 'lib/coder/cleaner/simple.rb', line 18 def clean(str) bytes = ByteBuffer.new(@encoding) str.each_byte { |b| bytes << b } force_encoding bytes.to_s end |