Sha256: 5ae7bbdd2a577e515c8906b7a45f31ec2582b40e2104c2b52ed712d394ee4409

Contents?: true

Size: 905 Bytes

Versions: 5

Compression:

Stored size: 905 Bytes

Contents

require 'nmap/cpe/url'

module Nmap
  #
  # Mixins that adds methods for parsing [Common Platform Enumeration
  # (CPE)][CPE] information.
  #
  # [CPE]: http://nmap.org/book/output-formats-cpe.html
  #
  # @since 0.7.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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-nmap-0.10.0 lib/nmap/cpe.rb
ruby-nmap-0.9.3 lib/nmap/cpe.rb
ruby-nmap-0.9.2 lib/nmap/cpe.rb
ruby-nmap-0.9.1 lib/nmap/cpe.rb
ruby-nmap-0.9.0 lib/nmap/cpe.rb