Sha256: 9ab26a9b4b29ed549f69007fdf23c4837b7534bfae6de67bd9909f7e67ca2b75

Contents?: true

Size: 906 Bytes

Versions: 3

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)
    if content.is_a?(String)
      content
    elsif format.to_s == 'xml'
      content.to_xml
    elsif
      content.to_json
    end
  end

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

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

  def decode(content, format)
    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

3 entries across 3 versions & 1 rubygems

Version Path
zencoder-2.1.2 lib/zencoder/zencoder.rb
zencoder-2.1.1 lib/zencoder/zencoder.rb
zencoder-2.1.0 lib/zencoder/zencoder.rb