# File lib/mechanize/cookie_jar.rb, line 78
  def save_as(file, format = :yaml)
    jar = dup
    jar.cleanup true

    open(file, 'w') { |f|
      case format
      when :yaml then
        load_yaml

        YAML.dump(jar.jar, f)
      when :cookiestxt then
        jar.dump_cookiestxt(f)
      else
        raise ArgumentError, "Unknown cookie jar file format"
      end
    }

    self
  end