Class: SiteHub::Cookie
- Inherits:
-
Object
- Object
- SiteHub::Cookie
- Defined in:
- lib/sitehub/cookie.rb,
lib/sitehub/cookie/flag.rb,
lib/sitehub/cookie/attribute.rb
Defined Under Namespace
Constant Summary collapse
- FIRST =
0
Instance Attribute Summary collapse
-
#attributes_and_flags ⇒ Object
readonly
Returns the value of attribute attributes_and_flags.
-
#name_attribute ⇒ Object
readonly
Returns the value of attribute name_attribute.
Instance Method Summary collapse
- #find(name) ⇒ Object
-
#initialize(cookie_string) ⇒ Cookie
constructor
A new instance of Cookie.
- #name ⇒ Object
- #to_s ⇒ Object
- #value ⇒ Object
Methods included from Equality
Constructor Details
#initialize(cookie_string) ⇒ Cookie
Returns a new instance of Cookie.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sitehub/cookie.rb', line 12 def initialize() @attributes_and_flags = .split(SEMICOLON).map do |entry| if entry.include?(EQUALS_SIGN) Cookie::Attribute.new(*entry.split(EQUALS_SIGN)) else Cookie::Flag.new(entry) end end name_attribute = @attributes_and_flags.delete_at(FIRST) @name_attribute = Cookie::Attribute.new(name_attribute.name.to_s, name_attribute.value) end |
Instance Attribute Details
#attributes_and_flags ⇒ Object (readonly)
Returns the value of attribute attributes_and_flags.
7 8 9 |
# File 'lib/sitehub/cookie.rb', line 7 def attributes_and_flags @attributes_and_flags end |
#name_attribute ⇒ Object (readonly)
Returns the value of attribute name_attribute.
7 8 9 |
# File 'lib/sitehub/cookie.rb', line 7 def name_attribute @name_attribute end |
Instance Method Details
#find(name) ⇒ Object
33 34 35 |
# File 'lib/sitehub/cookie.rb', line 33 def find(name) attributes_and_flags.find { |entry| entry.name == name } end |
#name ⇒ Object
25 26 27 |
# File 'lib/sitehub/cookie.rb', line 25 def name name_attribute.name end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/sitehub/cookie.rb', line 37 def to_s [name_attribute].concat(attributes_and_flags).join(SEMICOLON_WITH_SPACE) end |
#value ⇒ Object
29 30 31 |
# File 'lib/sitehub/cookie.rb', line 29 def value name_attribute.value end |