Class: Rubroxy::Handler::URLCapture
- Inherits:
-
Object
- Object
- Rubroxy::Handler::URLCapture
- Defined in:
- lib/rubroxy/handlers/url_capture.rb
Overview
Captures URLs, stores the results in a hash as the handler Proc object is called.
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
Instance Method Summary collapse
-
#clear ⇒ Hash
Clears the objects URL hash.
-
#initialize ⇒ Hash
constructor
Creates a new URLCapture object.
-
#write(url) ⇒ Hash
Writes to the URL collection.
Constructor Details
#initialize ⇒ Hash
Creates a new URLCapture object. Sets up the hash to store URLs
11 12 13 |
# File 'lib/rubroxy/handlers/url_capture.rb', line 11 def initialize setup_collection end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
6 7 8 |
# File 'lib/rubroxy/handlers/url_capture.rb', line 6 def collection @collection end |
Instance Method Details
#clear ⇒ Hash
Clears the objects URL hash.
32 33 34 |
# File 'lib/rubroxy/handlers/url_capture.rb', line 32 def clear setup_collection end |
#write(url) ⇒ Hash
Writes to the URL collection. It attempts to find the key matching the URL captured and increments the value if found. If not, it will create a new key value pair.
21 22 23 24 25 26 27 |
# File 'lib/rubroxy/handlers/url_capture.rb', line 21 def write(url) if @collection[:uris].key?(url) @collection[:uris][url] += 1 else @collection[:uris].merge!(url => 1) end end |