Class: PureCDB::SysIOWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/purecdb/base.rb

Overview

Wrap an object that does not have all of sysseek/syswrite/sysread but that does have seek/write/read with similar semantics. This is primarily intended for use with StringIO, which lacks syseek

It is automatically interjected on creating a PureCDB::Reader or +PureCDB::Writer if the IO-like object that is passed lacks sysseek so you should normally not need to think about this class

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ SysIOWrapper

Returns a new instance of SysIOWrapper.



134
135
136
# File 'lib/purecdb/base.rb', line 134

def initialize target
  @target = target
end

Instance Method Details

#sysread(size) ⇒ Object

Delegates to read



144
145
146
# File 'lib/purecdb/base.rb', line 144

def sysread(size)
  @target.read(size)
end

#sysseek(offset, mode) ⇒ Object

Delegates to seek



139
140
141
# File 'lib/purecdb/base.rb', line 139

def sysseek(offset,mode)
  @target.seek(offset,mode)
end

#syswrite(buffer) ⇒ Object

Delegates to write



149
150
151
# File 'lib/purecdb/base.rb', line 149

def syswrite(buffer)
  @target.write(buffer)
end