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
16 def initialize(body)
17   @raw = body
18 end

Public Instance methods

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