Class: Protocol::HTTP::Body::Wrapper

Inherits:
Readable
  • Object
show all
Defined in:
lib/protocol/http/body/wrapper.rb

Overview

Wrapping body instance. Typically you’d override ‘#read`.

Direct Known Subclasses

Completable, Digestable, Rewindable, ZStream

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Readable

#each, #join

Constructor Details

#initialize(body) ⇒ Wrapper

Returns a new instance of Wrapper.



19
20
21
# File 'lib/protocol/http/body/wrapper.rb', line 19

def initialize(body)
	@body = body
end

Instance Attribute Details

#bodyObject (readonly)

The wrapped body.



24
25
26
# File 'lib/protocol/http/body/wrapper.rb', line 24

def body
  @body
end

Class Method Details

.wrap(message) ⇒ Object



13
14
15
16
17
# File 'lib/protocol/http/body/wrapper.rb', line 13

def self.wrap(message)
	if body = message.body
		message.body = self.new(body)
	end
end

Instance Method Details

#call(stream) ⇒ Object



62
63
64
# File 'lib/protocol/http/body/wrapper.rb', line 62

def call(stream)
	@body.call(stream)
end

#close(error = nil) ⇒ Object



31
32
33
34
35
# File 'lib/protocol/http/body/wrapper.rb', line 31

def close(error = nil)
	@body.close(error)
	
	super
end

#empty?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/protocol/http/body/wrapper.rb', line 37

def empty?
	@body.empty?
end

#finishObject

Buffer any remaining body.



27
28
29
# File 'lib/protocol/http/body/wrapper.rb', line 27

def finish
	@body.finish
end

#inspectObject



54
55
56
# File 'lib/protocol/http/body/wrapper.rb', line 54

def inspect
	@body.inspect
end

#lengthObject



45
46
47
# File 'lib/protocol/http/body/wrapper.rb', line 45

def length
	@body.length
end

#readObject

Read the next available chunk.



50
51
52
# File 'lib/protocol/http/body/wrapper.rb', line 50

def read
	@body.read
end

#ready?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/protocol/http/body/wrapper.rb', line 41

def ready?
	@body.ready?
end

#stream?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/protocol/http/body/wrapper.rb', line 58

def stream?
	@body.stream?
end