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.



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

def initialize(body)
	@body = body
end

Instance Attribute Details

#bodyObject (readonly)

The wrapped body.



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

def body
  @body
end

Class Method Details

.wrap(message) ⇒ Object



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

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

Instance Method Details

#call(stream) ⇒ Object



79
80
81
# File 'lib/protocol/http/body/wrapper.rb', line 79

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

#close(error = nil) ⇒ Object



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

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

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
	@body.empty?
end

#finishObject

Buffer any remaining body.



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

def finish
	@body.finish
end

#inspectObject



71
72
73
# File 'lib/protocol/http/body/wrapper.rb', line 71

def inspect
	@body.inspect
end

#lengthObject



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

def length
	@body.length
end

#readObject

Read the next available chunk.



67
68
69
# File 'lib/protocol/http/body/wrapper.rb', line 67

def read
	@body.read
end

#ready?Boolean

Returns:

  • (Boolean)


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

def ready?
	@body.ready?
end

#stream?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/protocol/http/body/wrapper.rb', line 75

def stream?
	@body.stream?
end