Class: Nmap::XML::CPE::URL
- Inherits:
-
Struct
- Object
- Struct
- Nmap::XML::CPE::URL
- Defined in:
- lib/nmap/xml/cpe/url.rb
Overview
Represents a Common Platform Enumeration (CPE) URL.
Constant Summary collapse
- PARTS =
CPE part codes
{ '/a' => :application, '/h' => :hardware, '/o' => :os }
Instance Attribute Summary collapse
-
#edition ⇒ Object
Returns the value of attribute edition.
-
#language ⇒ Object
Returns the value of attribute language.
-
#part ⇒ Object
Returns the value of attribute part.
-
#product ⇒ Object
Returns the value of attribute product.
-
#update ⇒ Object
Returns the value of attribute update.
-
#vendor ⇒ Object
Returns the value of attribute vendor.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
-
.parse(url) ⇒ URL
Parses a CPE URL.
Instance Method Summary collapse
-
#to_s ⇒ String
Converts the CPE URL back into a String.
Instance Attribute Details
#edition ⇒ Object
Returns the value of attribute edition
13 14 15 |
# File 'lib/nmap/xml/cpe/url.rb', line 13 def edition @edition end |
#language ⇒ Object
Returns the value of attribute language
13 14 15 |
# File 'lib/nmap/xml/cpe/url.rb', line 13 def language @language end |
#part ⇒ Object
Returns the value of attribute part
13 14 15 |
# File 'lib/nmap/xml/cpe/url.rb', line 13 def part @part end |
#product ⇒ Object
Returns the value of attribute product
13 14 15 |
# File 'lib/nmap/xml/cpe/url.rb', line 13 def product @product end |
#update ⇒ Object
Returns the value of attribute update
13 14 15 |
# File 'lib/nmap/xml/cpe/url.rb', line 13 def update @update end |
#vendor ⇒ Object
Returns the value of attribute vendor
13 14 15 |
# File 'lib/nmap/xml/cpe/url.rb', line 13 def vendor @vendor end |
#version ⇒ Object
Returns the value of attribute version
13 14 15 |
# File 'lib/nmap/xml/cpe/url.rb', line 13 def version @version end |
Class Method Details
.parse(url) ⇒ URL
Parses a CPE URL.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/nmap/xml/cpe/url.rb', line 32 def self.parse(url) scheme, part, vendor, product, version, update, edition, language = url.split(':',8) unless scheme == 'cpe' raise(ArgumentError,"CPE URLs must begin with 'cpe:'") end vendor = vendor.to_sym product = product.to_sym language = language.to_sym if language return new( PARTS[part], vendor, product, version, update, edition, language ) end |
Instance Method Details
#to_s ⇒ String
Converts the CPE URL back into a String.
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/nmap/xml/cpe/url.rb', line 67 def to_s 'cpe:' + [ PARTS.invert[part], vendor, product, version, update, edition, language ].compact.join(':') end |