Class: SmoothOperator::CookieJar

Inherits:
Hash
  • Object
show all
Defined in:
lib/smooth_operator/cookie_jar.rb

Instance Method Summary collapse

Instance Method Details

#parse(*cookie_strings) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/smooth_operator/cookie_jar.rb', line 8

def parse(*cookie_strings)
  cookie_strings.each do |cookie_string|
    next unless cookie_string.is_a?(String)

    key, value = cookie_string.split('; ').first.split('=', 2)

    self[key] = value
  end

  self
end

#to_sObject



4
5
6
# File 'lib/smooth_operator/cookie_jar.rb', line 4

def to_s
  self.map { |key, value| "#{key}=#{value}"}.join("; ")
end