Class: UV::CookieJar
- Inherits:
-
Object
- Object
- UV::CookieJar
- Defined in:
- lib/uv-rays/http_endpoint.rb
Instance Method Summary collapse
- #get(uri) ⇒ Object
- #get_hash(uri) ⇒ Object
-
#initialize ⇒ CookieJar
constructor
A new instance of CookieJar.
- #set(string, uri) ⇒ Object
Constructor Details
#initialize ⇒ CookieJar
Returns a new instance of CookieJar.
3 4 5 |
# File 'lib/uv-rays/http_endpoint.rb', line 3 def initialize @jar = ::CookieJar::Jar.new end |
Instance Method Details
#get(uri) ⇒ Object
11 12 13 14 |
# File 'lib/uv-rays/http_endpoint.rb', line 11 def get(uri) uri = URI.parse(uri) rescue nil uri ? @jar.(uri).map(&:to_s) : [] end |
#get_hash(uri) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/uv-rays/http_endpoint.rb', line 16 def get_hash(uri) uri = URI.parse(uri) rescue nil = {} if uri @jar.(uri).each do || [.name.to_sym] = .value end end end |
#set(string, uri) ⇒ Object
7 8 9 |
# File 'lib/uv-rays/http_endpoint.rb', line 7 def set(string, uri) @jar.(uri, string) rescue nil # drop invalid cookies end |