module BinData::IO::Common

Common operations for both Read and Write.

Public Class Methods

new(io) click to toggle source
# 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