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.



55
56
57
58
# File 'lib/http/features/auto_deflate.rb', line 55

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

Instance Method Details

#each(&block) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/http/features/auto_deflate.rb', line 65

def each(&block)
  return to_enum __method__ unless block

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

  self
end

#sizeObject



60
61
62
63
# File 'lib/http/features/auto_deflate.rb', line 60

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