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

Rewindable, Streamable, ZStream

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Readable

#each, #join

Constructor Details

#initialize(body) ⇒ Wrapper

Returns a new instance of Wrapper.



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

def initialize(body)
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

The wrapped body.



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

def body
  @body
end

Instance Method Details

#close(error = nil) ⇒ Object



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

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

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  @body.empty?
end

#finishObject

Buffer any remaining body.



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

def finish
  @body.finish
end

#inspectObject



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

def inspect
  @body.inspect
end

#lengthObject



52
53
54
# File 'lib/protocol/http/body/wrapper.rb', line 52

def length
  @body.length
end

#readObject

Read the next available chunk.



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

def read
  @body.read
end