Sha256: 380e665ad336f3aad8934f134c048ce5303c524691350d50a11d436ee319be35

Contents?: true

Size: 1003 Bytes

Versions: 3

Compression:

Stored size: 1003 Bytes

Contents

require 'nmap/xml/cpe/url'

module Nmap
  class XML
    #
    # Mixins that adds methods for parsing [Common Platform Enumeration
    # (CPE)][CPE] information.
    #
    # [CPE]: http://nmap.org/book/output-formats-cpe.html
    #
    # @since 1.0.0
    #
    module CPE
      #
      # Parses each Common Platform Enumeration (CPE) String.
      #
      # @yield [cpe]
      #   Passes each CPE URL to the given block.
      #
      # @yieldparam [URL] cpe
      #   The CPE URL.
      #
      # @return [Enumerator]
      #   If no block is given, an enumerator object will be returned.
      #
      def each_cpe
        return enum_for(__method__) unless block_given?

        @node.xpath('cpe').each do |cpe|
          yield URL.parse(cpe.inner_text)
        end

        return self
      end

      #
      # Parses each Common Platform Enumeration (CPE) String.
      #
      # @return [Array<URL>]
      #   The CPE URLs.
      #
      def cpe
        each_cpe.to_a
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-nmap-1.0.2 lib/nmap/xml/cpe.rb
ruby-nmap-1.0.1 lib/nmap/xml/cpe.rb
ruby-nmap-1.0.0 lib/nmap/xml/cpe.rb