Class: QQBot::Cookie

Inherits:
Object
  • Object
show all
Defined in:
lib/qqbot/cookie.rb

Instance Method Summary collapse

Constructor Details

#initializeCookie

Returns a new instance of Cookie.



4
5
6
# File 'lib/qqbot/cookie.rb', line 4

def initialize
  @cookies = {}
end

Instance Method Details

#[](key) ⇒ Object



19
20
21
# File 'lib/qqbot/cookie.rb', line 19

def [] key
  @cookies[key] || ''
end

#put(set_cookie_array) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/qqbot/cookie.rb', line 8

def put set_cookie_array
  return if set_cookie_array.nil?

  set_cookie_array.each do |set_cookie|
    set_cookie.split('; ').each do |cookie|
      k, v = cookie.split('=')
      @cookies[k] = v unless v.nil?
    end
  end
end

#to_sObject



23
24
25
# File 'lib/qqbot/cookie.rb', line 23

def to_s
  @cookies.map{ |k, v| "#{k}=#{v}" }.join('; ')
end