Method: BinData::IO::Common#initialize

Defined in:
lib/bindata/io.rb

#initialize(io) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bindata/io.rb', line 10

def initialize(io)
  if self.class === io
    raise ArgumentError, "io must not be a #{self.class}"
  end

  # wrap strings in a StringIO
  if io.respond_to?(:to_str)
    io = BinData::IO.create_string_io(io.to_str)
  end

  @raw_io = io
  @buffer_end_pos = nil

  extend seekable? ? SeekableStream : UnSeekableStream
  stream_init
end