Class: Files::SizableIO

Inherits:
IO
  • Object
show all
Defined in:
lib/files.com/sizable_io.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.pipeObject



3
4
5
6
7
8
9
# File 'lib/files.com/sizable_io.rb', line 3

def self.pipe
  r, w = super

  w.instance_variable_set(:@read_io, r)

  [ r, w ]
end

Instance Method Details

#closeObject



20
21
22
23
# File 'lib/files.com/sizable_io.rb', line 20

def close
  super
  read_io.content_length_promise.try_set(nil)
end

#fulfill_content_length(length) ⇒ Object



15
16
17
18
# File 'lib/files.com/sizable_io.rb', line 15

def fulfill_content_length(length)
  read_io.content_length = length
  read_io.content_length_promise.execute
end

#sizeObject



11
12
13
# File 'lib/files.com/sizable_io.rb', line 11

def size
  read_io.content_length_promise.wait.value
end