Class: Typhoeus::Multi
- Inherits:
-
Object
- Object
- Typhoeus::Multi
- Defined in:
- lib/typhoeus/multi.rb,
ext/typhoeus/typhoeus_multi.c
Instance Attribute Summary collapse
-
#easy_handles ⇒ Object
readonly
Returns the value of attribute easy_handles.
Instance Method Summary collapse
- #add(easy) ⇒ Object
- #cleanup ⇒ Object
-
#initialize ⇒ Multi
constructor
A new instance of Multi.
- #perform ⇒ Object
- #remove(easy) ⇒ Object
- #reset_easy_handles ⇒ Object
Constructor Details
#initialize ⇒ Multi
Returns a new instance of Multi.
5 6 7 |
# File 'lib/typhoeus/multi.rb', line 5 def initialize @easy_handles = [] end |
Instance Attribute Details
#easy_handles ⇒ Object (readonly)
Returns the value of attribute easy_handles.
3 4 5 |
# File 'lib/typhoeus/multi.rb', line 3 def easy_handles @easy_handles end |
Instance Method Details
#add(easy) ⇒ Object
13 14 15 16 17 |
# File 'lib/typhoeus/multi.rb', line 13 def add(easy) raise "trying to add easy handle twice" if @easy_handles.include?(easy) easy.set_headers() if easy.headers.empty? multi_add_handle(easy) end |
#cleanup ⇒ Object
26 27 28 |
# File 'lib/typhoeus/multi.rb', line 26 def cleanup() multi_cleanup end |
#perform ⇒ Object
19 20 21 22 23 24 |
# File 'lib/typhoeus/multi.rb', line 19 def perform() while active_handle_count > 0 do multi_perform end reset_easy_handles end |
#remove(easy) ⇒ Object
9 10 11 |
# File 'lib/typhoeus/multi.rb', line 9 def remove(easy) multi_remove_handle(easy) if @easy_handles.include?(easy) end |
#reset_easy_handles ⇒ Object
30 31 32 33 34 35 |
# File 'lib/typhoeus/multi.rb', line 30 def reset_easy_handles @easy_handles.dup.each do |easy| multi_remove_handle(easy) yield easy if block_given? end end |