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.



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

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

Instance Method Details

#each(&block) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/http/features/auto_deflate.rb', line 62

def each(&block)
  return to_enum __method__ unless block

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

  self
end

#sizeObject



57
58
59
60
# File 'lib/http/features/auto_deflate.rb', line 57

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