Method: Nmap::XML#each_task

Defined in:
lib/nmap/xml.rb

#each_task {|task| ... } ⇒ Enumerator

Parses the tasks of the scan.

Yields:

  • (task)

    The given block will be passed each scan task.

Yield Parameters:

  • task (ScanTask)

    A task from the scan.

Returns:

  • (Enumerator)

    If no block is given, an enumerator will be returned.

Since:

  • 0.7.0


216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/nmap/xml.rb', line 216

def each_task
  return enum_for(__method__) unless block_given?

  @doc.xpath('/nmaprun/taskbegin').each do |task_begin|
    task_end = task_begin.xpath('following-sibling::taskend').first

    yield ScanTask.new(
      task_begin['task'],
      Time.at(task_begin['time'].to_i),
      Time.at(task_end['time'].to_i),
      task_end['extrainfo']
    )
  end

  return self
end