lib/io_streams/encode/writer.rb in iostreams-1.0.0.beta vs lib/io_streams/encode/writer.rb in iostreams-1.0.0.beta2
- old
+ new
@@ -38,10 +38,11 @@
super(output_stream)
@cleaner = ::IOStreams::Encode::Reader.send(:extract_cleaner, cleaner)
@encoding = encoding.nil? || encoding.is_a?(Encoding) ? encoding : Encoding.find(encoding)
@encoding_options = replace.nil? ? {} : {invalid: :replace, undef: :replace, replace: replace}
+ @replace = replace
end
# Write a line to the output stream
#
# Example:
@@ -64,10 +65,10 @@
def write(data)
return 0 if data.nil?
data = data.to_s
block = data.encoding == @encoding ? data : data.encode(@encoding, @encoding_options)
- block = @cleaner.call(block) if @cleaner
+ block = @cleaner.call(block, @replace) if @cleaner
@output_stream.write(block)
end
end
end
end