Module: BinData::IO::Common

Included in:
Read, Write
Defined in:
lib/bindata/io.rb

Overview

Common operations for both Read and Write.

Defined Under Namespace

Modules: SeekableStream, UnSeekableStream

Instance Method Summary collapse

Instance Method Details

#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_points = nil

  extend seekable? ? SeekableStream : UnSeekableStream
  stream_init
end