Module: Ethon::Multi::Stack

Included in:
Ethon::Multi
Defined in:
lib/ethon/multi/stack.rb

Overview

This module provides the multi stack behaviour.

Instance Method Summary collapse

Instance Method Details

#add(easy) ⇒ Object

Add an easy to the stack.

Examples:

Add easy.

multi.add(easy)

Parameters:

  • easy (Easy)

    The easy to add.

Raises:


25
26
27
28
29
30
31
# File 'lib/ethon/multi/stack.rb', line 25

def add(easy)
  return nil if easy_handles.include?(easy)

  code = Curl.multi_add_handle(handle, easy.handle)
  raise Errors::MultiAdd.new(code, easy) unless code == :ok
  easy_handles << easy
end

#delete(easy) ⇒ Object

Delete an easy from stack.

Examples:

Delete easy from stack.

Parameters:

  • easy (Easy)

    The easy to delete.

Raises:


40
41
42
43
44
45
# File 'lib/ethon/multi/stack.rb', line 40

def delete(easy)
  if easy_handles.delete(easy)
    code = Curl.multi_remove_handle(handle, easy.handle)
    raise Errors::MultiRemove.new(code, handle) unless code == :ok
  end
end

#easy_handlesArray

Return easy handles.

Examples:

Return easy handles.

multi.easy_handles

Returns:

  • (Array)

    The easy handles.


13
14
15
# File 'lib/ethon/multi/stack.rb', line 13

def easy_handles
  @easy_handles ||= []
end