Class: Async::HTTP::BufferedBody

Inherits:
Object
  • Object
show all
Defined in:
lib/async/http/body.rb

Defined Under Namespace

Modules: Reader

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ BufferedBody

Returns a new instance of BufferedBody.



68
69
70
71
72
73
74
# File 'lib/async/http/body.rb', line 68

def initialize(body)
  @chunks = []
  
  body.each do |chunk|
    @chunks << chunk
  end
end

Instance Method Details

#closed?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/async/http/body.rb', line 86

def closed?
  true
end

#each(&block) ⇒ Object



76
77
78
# File 'lib/async/http/body.rb', line 76

def each(&block)
  @chunks.each(&block)
end

#readObject Also known as: join



80
81
82
# File 'lib/async/http/body.rb', line 80

def read
  @buffer ||= @chunks.join
end