Class: HTTPX::Plugins::Compression::Encoder
- Inherits:
-
Object
- Object
- HTTPX::Plugins::Compression::Encoder
- Defined in:
- lib/httpx/plugins/compression.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
Instance Method Summary collapse
- #bytesize ⇒ Object
- #each(&blk) ⇒ Object
-
#initialize(body, deflater) ⇒ Encoder
constructor
A new instance of Encoder.
Constructor Details
#initialize(body, deflater) ⇒ Encoder
Returns a new instance of Encoder.
131 132 133 134 135 136 |
# File 'lib/httpx/plugins/compression.rb', line 131 def initialize(body, deflater) @content_type = body.content_type @body = body.respond_to?(:read) ? body : StringIO.new(body.to_s) @buffer = StringIO.new("".b, File::RDWR) @deflater = deflater end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
129 130 131 |
# File 'lib/httpx/plugins/compression.rb', line 129 def content_type @content_type end |
Instance Method Details
#bytesize ⇒ Object
147 148 149 150 |
# File 'lib/httpx/plugins/compression.rb', line 147 def bytesize deflate @buffer.size end |
#each(&blk) ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/httpx/plugins/compression.rb', line 138 def each(&blk) return enum_for(__method__) unless blk return deflate(&blk) if @buffer.size.zero? @buffer.rewind @buffer.each(&blk) end |