Class: HTTPX::Transcoder::Body::Encoder
- Inherits:
-
Object
- Object
- HTTPX::Transcoder::Body::Encoder
show all
- Extended by:
- Forwardable
- Defined in:
- lib/httpx/transcoder/body.rb
Instance Method Summary
collapse
Constructor Details
#initialize(body) ⇒ Encoder
Returns a new instance of Encoder.
18
19
20
|
# File 'lib/httpx/transcoder/body.rb', line 18
def initialize(body)
@raw = body
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
48
49
50
51
52
|
# File 'lib/httpx/transcoder/body.rb', line 48
def method_missing(meth, *args, &block)
return super unless @raw.respond_to?(meth)
@raw.__send__(meth, *args, &block)
end
|
Instance Method Details
#bytesize ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/httpx/transcoder/body.rb', line 22
def bytesize
if @raw.respond_to?(:bytesize)
@raw.bytesize
elsif @raw.respond_to?(:to_ary)
@raw.sum(&:bytesize)
elsif @raw.respond_to?(:size)
@raw.size || Float::INFINITY
elsif @raw.respond_to?(:length)
@raw.length || Float::INFINITY
elsif @raw.respond_to?(:each)
Float::INFINITY
else
raise Error, "cannot determine size of body: #{@raw.inspect}"
end
end
|
#content_type ⇒ Object
38
39
40
|
# File 'lib/httpx/transcoder/body.rb', line 38
def content_type
"application/octet-stream"
end
|