Class: HTTP::CookieJar::CookiestxtSaver

Inherits:
AbstractSaver show all
Defined in:
lib/http/cookie_jar/cookiestxt_saver.rb

Overview

CookiestxtSaver saves and loads cookies in the cookies.txt format.

Instance Method Summary collapse

Methods inherited from AbstractSaver

class_to_symbol, implementation, inherited, #initialize

Constructor Details

This class inherits a constructor from HTTP::CookieJar::AbstractSaver

Instance Method Details

#load(io, jar) ⇒ Object



32
33
34
35
36
# File 'lib/http/cookie_jar/cookiestxt_saver.rb', line 32

def load(io, jar)
  io.each_line { |line|
    cookie = parse_record(line) and jar.add(cookie)
  }
end

#save(io, jar) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/http/cookie_jar/cookiestxt_saver.rb', line 24

def save(io, jar)
  io.puts @header if @header
  jar.each { |cookie|
    next if !@session && cookie.session?
    io.print cookie_to_record(cookie)
  }
end