Subversion Info

Rev
406
Last Checked In
2007-07-18 17:01:59 (9 months ago)
Checked in by
bbleything

Parent

Included Modules

Class Index

Quicksearch

Arrow::CookieSet

An object class which provides convenience functions for accessing a set of Arrow::Cookie objects.

Constants

SVNRev
SVN Revision
SVNId
SVN Id

Public Class Methods

new( *cookies ) click to toggle source

Create a new CookieSet prepopulated with the given cookies

    # File /Users/ged/source/ruby/Arrow/lib/arrow/cookieset.rb, line 61
61:     def initialize( *cookies )
62:         @cookie_set = Set.new( cookies.flatten )
63:     end

Public Instance Methods

<<( cookie ) click to toggle source

Append operator: Add the given cookie to the set, replacing an existing cookie with the same name if one exists.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/cookieset.rb, line 112
112:     def <<( cookie )
113:         @cookie_set.delete( cookie )
114:         @cookie_set.add( cookie )
115:         
116:         return self
117:     end
[]( name ) click to toggle source

Index operator method: returns the Arrow::Cookie with the given name if it exists in the cookieset.

    # File /Users/ged/source/ruby/Arrow/lib/arrow/cookieset.rb, line 82
82:     def []( name )
83:         name = name.to_s
84:         return @cookie_set.find() {|cookie| cookie.name == name }
85:     end
[]=( name, value ) click to toggle source

Index set operator method: set the cookie that corresponds to the given name to value. If value is not an Arrow::Cookie, one with be created and its value set to value.

    # File /Users/ged/source/ruby/Arrow/lib/arrow/cookieset.rb, line 91
91:     def []=( name, value )
92:         value = Arrow::Cookie.new( name.to_s, value ) unless value.is_a?( Arrow::Cookie )
93:         raise ArgumentError, "cannot set a cookie named '%s' with a key of '%s'" %
94:             [ value.name, name ] if value.name.to_s != name.to_s
95: 
96:         self << value
97:     end
include?( name_or_cookie ) click to toggle source

Returns true if the CookieSet includes either a cookie with the given name or an Arrow::Cookie object.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/cookieset.rb, line 102
102:     def include?( name_or_cookie )
103:         return true if @cookie_set.include?( name_or_cookie )
104:         name = name_or_cookie.to_s
105:         return self[name] ? true : false
106:     end
Also aliased as: key?
key?( name_or_cookie ) click to toggle source

Alias for #include?

length() click to toggle source

Returns the number of cookies in the cookieset

    # File /Users/ged/source/ruby/Arrow/lib/arrow/cookieset.rb, line 74
74:     def length
75:         return @cookie_set.length
76:     end
Also aliased as: size
size() click to toggle source

Alias for #length

secsequence

--- SEC00039

seccomment

--- ""

method_list

--- 
- methods: 
  - visibility: public
    aref: M000531
    name: new
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/cookieset.rb, line 61</span>\n\
      61:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">initialize</span>( <span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">cookies</span> )\n\
      62:         <span class=\"ruby-ivar\">@cookie_set</span> = <span class=\"ruby-constant\">Set</span>.<span class=\"ruby-identifier\">new</span>( <span class=\"ruby-identifier\">cookies</span>.<span class=\"ruby-identifier\">flatten</span> )\n\
      63:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Create a <a href="CookieSet.html#M000531">new</a> <a
      href="CookieSet.html">CookieSet</a> prepopulated with the given cookies
      </p>
    params: ( *cookies )
  category: Class
  type: Public
- methods: 
  - visibility: public
    aref: M000538
    name: "&lt;&lt;"
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/cookieset.rb, line 112</span>\n\
      112:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-operator\">&lt;&lt;</span>( <span class=\"ruby-identifier\">cookie</span> )\n\
      113:         <span class=\"ruby-ivar\">@cookie_set</span>.<span class=\"ruby-identifier\">delete</span>( <span class=\"ruby-identifier\">cookie</span> )\n\
      114:         <span class=\"ruby-ivar\">@cookie_set</span>.<span class=\"ruby-identifier\">add</span>( <span class=\"ruby-identifier\">cookie</span> )\n\
      115:         \n\
      116:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">self</span>\n\
      117:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Append operator: Add the given <tt>cookie</tt> to the set, replacing an
      existing cookie with the same name if one exists.
      </p>
    params: ( cookie )
  - visibility: public
    aref: M000534
    name: "[]"
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/cookieset.rb, line 82</span>\n\
      82:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-operator\">[]</span>( <span class=\"ruby-identifier\">name</span> )\n\
      83:         <span class=\"ruby-identifier\">name</span> = <span class=\"ruby-identifier\">name</span>.<span class=\"ruby-identifier\">to_s</span>\n\
      84:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-ivar\">@cookie_set</span>.<span class=\"ruby-identifier\">find</span>() {<span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">cookie</span><span class=\"ruby-operator\">|</span> <span class=\"ruby-identifier\">cookie</span>.<span class=\"ruby-identifier\">name</span> <span class=\"ruby-operator\">==</span> <span class=\"ruby-identifier\">name</span> }\n\
      85:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Index operator method: returns the <a href="Cookie.html">Arrow::Cookie</a>
      with the given <tt>name</tt> if it exists in the cookieset.
      </p>
    params: ( name )
  - visibility: public
    aref: M000535
    name: "[]="
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/cookieset.rb, line 91</span>\n\
      91:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-operator\">[]=</span>( <span class=\"ruby-identifier\">name</span>, <span class=\"ruby-identifier\">value</span> )\n\
      92:         <span class=\"ruby-identifier\">value</span> = <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Cookie</span>.<span class=\"ruby-identifier\">new</span>( <span class=\"ruby-identifier\">name</span>.<span class=\"ruby-identifier\">to_s</span>, <span class=\"ruby-identifier\">value</span> ) <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-identifier\">value</span>.<span class=\"ruby-identifier\">is_a?</span>( <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Cookie</span> )\n\
      93:         <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">ArgumentError</span>, <span class=\"ruby-value str\">&quot;cannot set a cookie named '%s' with a key of '%s'&quot;</span> <span class=\"ruby-operator\">%</span>\n\
      94:             [ <span class=\"ruby-identifier\">value</span>.<span class=\"ruby-identifier\">name</span>, <span class=\"ruby-identifier\">name</span> ] <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">value</span>.<span class=\"ruby-identifier\">name</span>.<span class=\"ruby-identifier\">to_s</span> <span class=\"ruby-operator\">!=</span> <span class=\"ruby-identifier\">name</span>.<span class=\"ruby-identifier\">to_s</span>\n\
      95: \n\
      96:         <span class=\"ruby-keyword kw\">self</span> <span class=\"ruby-operator\">&lt;&lt;</span> <span class=\"ruby-identifier\">value</span>\n\
      97:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Index set operator method: set the cookie that corresponds to the given
      <tt>name</tt> to <tt>value</tt>. If <tt>value</tt> is not an <a
      href="Cookie.html">Arrow::Cookie</a>, one with be created and its value set
      to <tt>value</tt>.
      </p>
    params: ( name, value )
  - visibility: public
    aref: M000536
    name: include?
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/cookieset.rb, line 102</span>\n\
      102:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">include?</span>( <span class=\"ruby-identifier\">name_or_cookie</span> )\n\
      103:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">true</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-ivar\">@cookie_set</span>.<span class=\"ruby-identifier\">include?</span>( <span class=\"ruby-identifier\">name_or_cookie</span> )\n\
      104:         <span class=\"ruby-identifier\">name</span> = <span class=\"ruby-identifier\">name_or_cookie</span>.<span class=\"ruby-identifier\">to_s</span>\n\
      105:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">self</span>[<span class=\"ruby-identifier\">name</span>] <span class=\"ruby-operator\">?</span> <span class=\"ruby-keyword kw\">true</span> <span class=\"ruby-operator\">:</span> <span class=\"ruby-keyword kw\">false</span>\n\
      106:     <span class=\"ruby-keyword kw\">end</span>"
    aka: 
    - aref: CookieSet.html#M000537
      name: key?
    m_desc: |-
      <p>
      Returns <tt>true</tt> if the <a href="CookieSet.html">CookieSet</a>
      includes either a cookie with the given name or an <a
      href="Cookie.html">Arrow::Cookie</a> object.
      </p>
    params: ( name_or_cookie )
  - visibility: public
    aref: M000537
    name: key?
    m_desc: |-
      <p>
      Alias for #include?
      </p>
    params: ( name_or_cookie )
  - visibility: public
    aref: M000532
    name: length
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/cookieset.rb, line 74</span>\n\
      74:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">length</span>\n\
      75:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-ivar\">@cookie_set</span>.<span class=\"ruby-identifier\">length</span>\n\
      76:     <span class=\"ruby-keyword kw\">end</span>"
    aka: 
    - aref: CookieSet.html#M000533
      name: size
    m_desc: |-
      <p>
      Returns the number of cookies in the cookieset
      </p>
    params: ()
  - visibility: public
    aref: M000533
    name: size
    m_desc: |-
      <p>
      Alias for <a href="CookieSet.html#M000532">#length</a>
      </p>
    params: ()
  category: Instance
  type: Public

sectitle

--- 

constants

--- 
- name: SVNRev
  desc: |+
    
    SVN Revision
    
  value: "%q$Rev: 406 $"
- name: SVNId
  desc: |+
    
    SVN Id
    
  value: "%q$Id: cookieset.rb 406 2007-07-18 17:01:59Z bbleything $"

[Validate]

Generated with the Darkfish Rdoc Generator.