From e3c8152e016fe29f76a996b8802df7158c081db0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 26 Apr 2011 12:56:20 -0700 Subject: stream_file: hide internals No need to expose things that don't need exposing. --- lib/rainbows/stream_file.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/rainbows/stream_file.rb b/lib/rainbows/stream_file.rb index 4a77a2f..08a9c2d 100644 --- a/lib/rainbows/stream_file.rb +++ b/lib/rainbows/stream_file.rb @@ -5,10 +5,17 @@ # models. We always maintain our own file offsets in userspace because # because sendfile() implementations offer pread()-like idempotency for # concurrency (multiple clients can read the same underlying file handle). -class Rainbows::StreamFile < Struct.new(:offset, :count, :to_io, :body) +class Rainbows::StreamFile + attr_reader :to_io + attr_accessor :offset, :count + + def initialize(offset, count, io, body) + @offset, @count, @to_io, @body = offset, count, io, body + end + def close - body.close if body.respond_to?(:close) - to_io.close unless to_io.closed? - self.to_io = nil + @body.close if @body.respond_to?(:close) + @to_io.close unless @to_io.closed? + @to_io = nil end end -- cgit v1.2.3-24-ge0c7