Class: HTTP::Features::AutoDeflate::CompressedBody

Inherits:
Request::Body
  • Object
show all
Defined in:
lib/http/features/auto_deflate.rb

Direct Known Subclasses

DeflatedBody, GzippedBody

Instance Attribute Summary

Attributes inherited from Request::Body

#source

Instance Method Summary collapse

Methods inherited from Request::Body

#==

Constructor Details

#initialize(uncompressed_body) ⇒ CompressedBody

Returns a new instance of CompressedBody.



46
47
48
49
# File 'lib/http/features/auto_deflate.rb', line 46

def initialize(uncompressed_body)
  @body       = uncompressed_body
  @compressed = nil
end

Instance Method Details

#each(&block) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/http/features/auto_deflate.rb', line 56

def each(&block)
  return to_enum __method__ unless block

  if @compressed
    compressed_each(&block)
  else
    compress(&block)
  end

  self
end

#sizeObject



51
52
53
54
# File 'lib/http/features/auto_deflate.rb', line 51

def size
  compress_all! unless @compressed
  @compressed.size
end