Class: BulkProcessor::StreamEncoder
- Inherits:
-
Object
- Object
- BulkProcessor::StreamEncoder
- Defined in:
- lib/bulk_processor/stream_encoder.rb
Overview
Force encode a stream into UTF-8 by removing invalid and undefined characters.
Instance Method Summary collapse
-
#encoded ⇒ String
Return the UTF-8 encoded string.
-
#initialize(stream) ⇒ StreamEncoder
constructor
A new instance of StreamEncoder.
Constructor Details
#initialize(stream) ⇒ StreamEncoder
Returns a new instance of StreamEncoder.
8 9 10 |
# File 'lib/bulk_processor/stream_encoder.rb', line 8 def initialize(stream) @stream = stream end |
Instance Method Details
#encoded ⇒ String
Return the UTF-8 encoded string.
Note: this method reads the stream, so it will need to be rewound before attempting to read again.
18 19 20 |
# File 'lib/bulk_processor/stream_encoder.rb', line 18 def encoded stream.read.encode(Encoding::UTF_8, ENCODING_OPTIONS) end |