def load_format requested_format = nil
      raise ArgumentError, "Requested format not supported" if !requested_format.nil? && @@formats[requested_format].nil?
      @format = requested_format || @@default_format
      attempted_formats = ""

      begin
        attempted_formats += @@formats[@format][:require]
        require @@formats[@format][:require]
        return true
      rescue LoadError
        # If the user requested the format and it failed. Just give up!
        raise Error("Please install: '#{@@formats[@format][:require]}' to use #{@format} format.") unless requested_format.nil?

        # Otherwise lets exhaust all our other options first
        available_formats = @@formats
        available_formats.delete(@format)
        
        available_formats.each_key do |format|
          begin
            attempted_formats += ", "            
            require @@formats[format][:require]
            
            @format = format
            return true
          rescue LoadError
            attempted_formats += @@formats[format][:require]
          end
        end
        
        raise Error, "Could not find any suitable library to parse response with, tried: #{attempted_formats}. Please install one of these to use OEmbed."
      end      
    end
def load_format requested_format = nil
      raise ArgumentError, "Requested format not supported" if !requested_format.nil? && @@formats[requested_format].nil?
      @format = requested_format || @@default_format
      attempted_formats = ""

      begin
        attempted_formats += @@formats[@format][:require]
        require @@formats[@format][:require]
        return true
      rescue LoadError
        # If the user requested the format and it failed. Just give up!
        raise Error("Please install: '#{@@formats[@format][:require]}' to use #{@format} format.") unless requested_format.nil?

        # Otherwise lets exhaust all our other options first
        available_formats = @@formats
        available_formats.delete(@format)
        
        available_formats.each_key do |format|
          begin
            attempted_formats += ", "            
            require @@formats[format][:require]
            
            @format = format
            return true
          rescue LoadError
            attempted_formats += @@formats[format][:require]
          end
        end
        
        raise Error, "Could not find any suitable library to parse response with, tried: #{attempted_formats}. Please install one of these to use OEmbed."
      end      
    end
def load_format requested_format = nil raise ArgumentError , "Requested format not supported" if ! requested_format . nil? && @@formats [ requested_format ] . nil? @format = requested_format || @@default_format attempted_formats = "" begin attempted_formats += @@formats [ @format ] [ :require ] require @@formats [ @format ] [ :require ] return true rescue LoadError # If the user requested the format and it failed. Just give up! raise Error ( "Please install: '#{@@formats[@format][:require]}' to use #{@format} format." ) unless requested_format . nil? # Otherwise lets exhaust all our other options first available_formats = @@formats available_formats . delete ( @format ) available_formats . each_key do | format | begin attempted_formats += ", " require @@formats [ format ] [ :require ] @format = format return true rescue LoadError attempted_formats += @@formats [ format ] [ :require ] end end raise Error , "Could not find any suitable library to parse response with, tried: #{attempted_formats}. Please install one of these to use OEmbed." end end
Call with no argument to use default
Call with no argument to use default