Class: Zencoder

Inherits:
Object
  • Object
show all
Defined in:
lib/zencoder/http/net_http.rb,
lib/zencoder/job.rb,
lib/zencoder/http.rb,
lib/zencoder/errors.rb,
lib/zencoder/output.rb,
lib/zencoder/account.rb,
lib/zencoder/version.rb,
lib/zencoder/response.rb,
lib/zencoder/zencoder.rb,
lib/zencoder/notification.rb,
lib/zencoder/http/typhoeus.rb

Overview

Ruby’s Net/HTTP Sucks Borrowed root cert checking from redcorundum.blogspot.com/2008/03/ssl-certificates-and-nethttps.html

Direct Known Subclasses

Account, HTTP, Job, Notification, Output, Response

Defined Under Namespace

Classes: Account, Error, HTTP, HTTPError, Job, Notification, Output, Response

Constant Summary collapse

VERSION =
'2.1.9'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.decode(content, format = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/zencoder/zencoder.rb', line 26

def self.decode(content, format=nil)
  if content.is_a?(String)
    if format.to_s == 'xml'
      Hash.from_xml(content)
    else
      ActiveSupport::JSON.decode(content)
    end
  else
    content
  end
end

.encode(content, format = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/zencoder/zencoder.rb', line 8

def self.encode(content, format=nil)
  if content.is_a?(String)
    content
  elsif format.to_s == 'xml'
    if content.is_a?(Hash) && content.keys.size == 1
      content[content.keys.first].to_xml(:root => content.keys.first)
    else
      content.to_xml
    end
  else
    content.to_json
  end
end

Instance Method Details

#decode(content, format = nil) ⇒ Object



38
39
40
# File 'lib/zencoder/zencoder.rb', line 38

def decode(content, format=nil)
  self.class.decode(content, format)
end

#encode(content, format = nil) ⇒ Object



22
23
24
# File 'lib/zencoder/zencoder.rb', line 22

def encode(content, format=nil)
  self.class.encode(content, format)
end