Sha256: c208c81b3f6ed1a1d4c73d4d68ffbf3eeb1961cb6d0b14c04ca209e1ed28ef7d

Contents?: true

Size: 906 Bytes

Versions: 5

Compression:

Stored size: 906 Bytes

Contents

class Zencoder

  cattr_accessor :base_url
  cattr_accessor :api_key

  self.base_url = 'https://app.zencoder.com/api'

  def self.encode(content, format=nil)
    if content.is_a?(String)
      content
    elsif format.to_s == 'xml'
      content.to_xml
    else
      content.to_json
    end
  end

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

  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

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


protected

  def self.merge_params(options, params)
    if options[:params]
      options[:params] = options[:params].merge(params)
      options
    else
      options.merge(:params => params)
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zencoder-2.1.8 lib/zencoder/zencoder.rb
zencoder-2.1.7 lib/zencoder/zencoder.rb
zencoder-2.1.6 lib/zencoder/zencoder.rb
zencoder-2.1.5 lib/zencoder/zencoder.rb
zencoder-2.1.4 lib/zencoder/zencoder.rb