Parses the tasks of the scan.

 @yield [task]
   The given block will be passed each scan task.

 @yieldparam [ScanTask] task
   A task from the scan.

 @return [Enumerator]
   If no block is given, an enumerator will be returned.

 @since 0.7.0
12244
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
457308
def each(&block)
      # TODO: Using block.call here is slower than using yield by 5-10%, but
      # the latter segfaults on ruby 2.2 and above. Once that is fixed and
      # broken versions are sufficiently old, we should revert back to yield
      # with a warning that the broken versions are unsupported.
      #
      # For more context:
      # * https://bugs.ruby-lang.org/issues/11451
      # * https://github.com/hamstergem/hamster/issues/189
      @entries.each { |entry| block.call(entry) if entry }
      @children.each do |child|
        child.each(&block) if child
      end
      nil
    end
1333346
def each_recursive(&block) # :yields: node
      self.elements.each {|node|
        block.call(node)
        node.each_recursive(&block)
      }
    end
1127197
def each(&block)
      if @iterate == :each_row
        @batched ? self.each_row_batch(&block) : self.each_row(&block)
      elsif @iterate == :each_array
        @batched ? self.each_array_batch(&block) : self.each_array(&block)
      else
        @batched ? self.each_instance_batch(@type, &block) : self.each_instance(@type, &block)
      end
    end
774897
def load_tasks
      return if @loaded

      # By convention, the '*_helper.rb' files are helpers and need to be loaded first. Load
      # them into the Thor::Sandbox namespace
      Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb')  ).each do |task|
        if task.match(/_helper\.rb$/)
          #logger.debug "load_thorfile helper: #{task}"
          ::Thor::Util.load_thorfile task
        end
      end

      # Now load the thor files
      Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb')  ).each do |task|
        unless task.match(/_helper\.rb$/)
          #logger.debug "load_thorfile: #{task}"
          ::Thor::Util.load_thorfile task
        end
      end

      # load user tasks
      if user_tasks_folder
        Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}'])  ).each { |task| ::Thor::Util.load_thorfile task if task.match(/_helper\.rb$/) }
        Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}'])  ).each { |task| ::Thor::Util.load_thorfile task unless task.match(/_helper\.rb$/) }
      end

      @loaded = true
    end
279012
def to_enum(match: '*', count: 10, with_scores: false)
      enumerator = self.connection.zscan_each(@key, match: match, count: count)
      return enumerator if with_scores
      return Enumerator.new do |yielder|
        loop do
          item, = enumerator.next
          yielder << item
        end
      end
    end
1295065
def task_group(name, *args, &block)
      if block
        @task_groups[name] = block
      else
        find_task_group(name).call(*args)
      end
    end
1040864
def enumerator
      response = get_initial_response
      Enumerator.new do |yielder|
        loop do
          response.records.each { |item| yielder << item }

          after_cursor = response.after
          break if after_cursor.nil?

          @options[:params] ||= {}
          @options[:params] = @options[:params].merge(after: after_cursor)
          response = @service.list(@options.merge(after: after_cursor))
        end
      end.lazy
    end
1103473
def each
      return enum_for(:each) unless block_given?

      pointer = self
      loop do
        break if pointer.null?
        yield pointer
        pointer = pointer.next
      end
    end
771244
def each_resource(&block)
      Enumerator.new do |result|
        each_page { |resources| resources.each { |resource| result << resource } }
      end.each(&block)
    end
1125628
def fetch_block(block_size=nil)
      block_size ||= @block_size ||= @options.fetch(:block_size) { 1000 }
      @result = @connection.execute("fetch #{block_size} from cursor_#{@cursor}")

      if @iterate == :each_array
        @block = @result.each_row.collect {|row| row }
      else
        @block = @result.collect {|row| row }
      end
    end
1044361
def run_actions
        catch_exceptions do
          @success = if block_given?
            result = yield
            actions.each {|action| results[action] = result}
            !!result
          else
            actions.compact.each {|action| !skip_actions && results[action] = object.send(action)}
            results.values.all?
          end
        end
      end
134106
def parse!
      unless @type.nil? || VALID_TASKS.include?(@type)
        raise TaskList::Exceptions::InvalidTaskTypeError.new type: @type
      end

      @files.each { |f| parsef! file: f }
    end
83916
def map(&block)
      return self.to_enum(:map) unless block_given?
      arr = []
      self.each_row do |row|
        arr.push(row.instance_eval(&block))
      end
      Mikon::Series.new(:new_series, arr, index: @index.clone)
    end
1119353
def each
      @data.each do |section, hash|
        hash.each do |key, value|
          yield [section, key, value]
        end
      end
    end
514758
def lines(name=nil) #:yield: Line
      # FIXME - this would be much easier if #lines was #each, and there was a
      # different #lines that returned an Enumerator that used #each
      unless block_given?
        map do |f|
          if( !name || f.name?(name) )
            f2l(f)
          else
            nil
          end
        end.compact
      else
        each do |f|
          if( !name || f.name?(name) )
            line = f2l(f)
            if line
              yield line
            end
          end
        end
        self
      end
    end
349217
def parse
      @commands.each do |_, cmd|
        if cmd.flags?
          # or for the || seems to not do what I want it to do...
          next unless argv_index = ARGV.index(cmd.flags.short) || ARGV.index(cmd.flags.long)
        else
          next unless argv_index = ARGV.index(cmd.index.to_s)
        end
        cmd.given = true unless argv_index.nil?
        if cmd.type.nil?
          yield cmd if block_given?
        else
          if parsed = parse_cmd(cmd, flags)
            cmd.arguments = parsed || cmd.default
            yield cmd if block_given?
          elsif cmd.default
            cmd.arguments = cmd.default
            yield cmd if block_given?
          end
        end
      end
    end