lib/io_streams/delimited/reader.rb in iostreams-0.9.0 vs lib/io_streams/delimited/reader.rb in iostreams-0.9.1

- old
+ new

@@ -1,9 +1,9 @@ module IOStreams module Delimited class Reader - attr_accessor :delimiter + attr_accessor :delimiter, :buffer_size, :encoding, :strip_non_printable # Read from a file or stream def self.open(file_name_or_io, options={}, &block) if IOStreams.reader_stream?(file_name_or_io) block.call(new(file_name_or_io, options)) @@ -52,11 +52,10 @@ @input_stream = input_stream options = options.dup @delimiter = options.delete(:delimiter) @buffer_size = options.delete(:buffer_size) || 65536 @encoding = options.has_key?(:encoding) ? options.delete(:encoding) : UTF8_ENCODING - @strip_non_printable = options.delete(:strip_non_printable) - @strip_non_printable = @strip_non_printable.nil? && (@encoding == UTF8_ENCODING) + @strip_non_printable = options.delete(:strip_non_printable) || false raise ArgumentError.new("Unknown IOStreams::Delimited::Reader#initialize options: #{options.inspect}") if options.size > 0 @delimiter.force_encoding(UTF8_ENCODING) if @delimiter && @encoding @buffer = '' end