Abstraction Layer
Handle Interface
All handles implement:
class Handle
def read(size)
# Read up to size bytes
end
def write(data)
# Write data
end
def seek(offset, whence = IO::SEEK_SET)
# Seek to position
end
def tell
# Return current position
end
def eof?
# Check if at end
end
def size
# Total size
end
def close
# Clean up resources
end
endImplementation Types
Performance considerations
-
Buffering: Critical for performance
-
Sequential access: Much faster than random
-
Memory vs I/O: Trade-offs based on use case