Class: Zencoder::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/zencoder/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.api_key ⇒ Object
4
5
6
|
# File 'lib/zencoder/base.rb', line 4
def self.api_key
Zencoder.api_key
end
|
.base_url ⇒ Object
8
9
10
|
# File 'lib/zencoder/base.rb', line 8
def self.base_url
Zencoder.base_url
end
|
.decode(content, format = nil) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/zencoder/base.rb', line 30
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
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/zencoder/base.rb', line 12
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
42
43
44
|
# File 'lib/zencoder/base.rb', line 42
def decode(content, format=nil)
self.class.decode(content, format)
end
|
#encode(content, format = nil) ⇒ Object
26
27
28
|
# File 'lib/zencoder/base.rb', line 26
def encode(content, format=nil)
self.class.encode(content, format)
end
|