Module: CookieMonster
- Defined in:
- lib/cookiemonster.rb,
lib/cookiemonster/version.rb
Defined Under Namespace
Classes: Cookie
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
Class Method Details
.parse(set_cookie_string) ⇒ Object
6 7 8 |
# File 'lib/cookiemonster.rb', line 6 def self.parse() Cookie.new self.parse_hash() end |
.parse_hash(set_cookie_string) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cookiemonster.rb', line 10 def self.parse_hash() hash = .split(/; ?/).inject({}) do |result, field| field_name, field_value = field.split('=', 2) result[field_name] = field_value result end name, value = hash.shift hash[:name] = name hash[:value] = value hash = hash.inject({}) do |, (key, value)| [(key.downcase.to_sym rescue key) || key] = value end hash end |