class HTTPX::Transcoder::Body::Encoder

  1. lib/httpx/transcoder/body.rb
Superclass: Object

Methods

Public Class

  1. new

Public Instance

  1. bytesize
  2. content_type

Public Class methods

new(body)
[show source]
   # File lib/httpx/transcoder/body.rb
18 def initialize(body)
19   @raw = body
20 end

Public Instance methods

bytesize()
[show source]
   # File lib/httpx/transcoder/body.rb
22 def bytesize
23   if @raw.respond_to?(:bytesize)
24     @raw.bytesize
25   elsif @raw.respond_to?(:to_ary)
26     @raw.sum(&:bytesize)
27   elsif @raw.respond_to?(:size)
28     @raw.size || Float::INFINITY
29   elsif @raw.respond_to?(:length)
30     @raw.length || Float::INFINITY
31   elsif @raw.respond_to?(:each)
32     Float::INFINITY
33   else
34     raise Error, "cannot determine size of body: #{@raw.inspect}"
35   end
36 end
content_type()
[show source]
   # File lib/httpx/transcoder/body.rb
38 def content_type
39   "application/octet-stream"
40 end