Class: Nmap::CPE::URL
- Inherits:
-
Struct
- Object
- Struct
- Nmap::CPE::URL
- Defined in:
- lib/nmap/cpe/url.rb
Overview
Represets 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
10 11 12 |
# File 'lib/nmap/cpe/url.rb', line 10 def edition @edition end |
#language ⇒ Object
Returns the value of attribute language
10 11 12 |
# File 'lib/nmap/cpe/url.rb', line 10 def language @language end |
#part ⇒ Object
Returns the value of attribute part
10 11 12 |
# File 'lib/nmap/cpe/url.rb', line 10 def part @part end |
#product ⇒ Object
Returns the value of attribute product
10 11 12 |
# File 'lib/nmap/cpe/url.rb', line 10 def product @product end |
#update ⇒ Object
Returns the value of attribute update
10 11 12 |
# File 'lib/nmap/cpe/url.rb', line 10 def update @update end |
#vendor ⇒ Object
Returns the value of attribute vendor
10 11 12 |
# File 'lib/nmap/cpe/url.rb', line 10 def vendor @vendor end |
#version ⇒ Object
Returns the value of attribute version
10 11 12 |
# File 'lib/nmap/cpe/url.rb', line 10 def version @version end |
Class Method Details
.parse(url) ⇒ URL
Parses a CPE URL.
29 30 31 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 |
# File 'lib/nmap/cpe/url.rb', line 29 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.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/nmap/cpe/url.rb', line 64 def to_s 'cpe:' + [ PARTS.invert[part], vendor, product, version, update, edition, language ].compact.join(':') end |