Class: Typhoeus::Multi

Inherits:
Object
  • Object
show all
Defined in:
lib/typhoeus/multi.rb,
ext/typhoeus/typhoeus_multi.c

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMulti

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_handlesObject (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

#cleanupObject



26
27
28
# File 'lib/typhoeus/multi.rb', line 26

def cleanup()
  multi_cleanup
end

#performObject



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_handlesObject



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