Method: CPE#initialize
- Defined in:
- lib/cpe.rb
#initialize(args = {}) ⇒ CPE
Public: Initialize a new CPE Object, initializing all relevent variables to passed values, or else an empty string. Part must be one of CPE::OS, CPE::Application, CPE::Hardware, or else be nil.
args - Hash containing values to set the CPE (default: {}):
:part - String describing the part. Must be one of CPE::OS,
CPE::Application or CPE::Hardware, or nil.
:vendor - String containing the name of the vendor of the part.
:product - String containing the name of the part described by the
CPE.
:version - String containing the version of the part.
:update - String describing the update/patch level of the part.
:edition - String containing any relevant edition text for the
part.
:language - String describing the language the part targets.
Raises ArgumentError if anything other than a Hash is passed. Raises ArgumentError if anything but ‘/o’, ‘/a’, or ‘/h’ are set as the part.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cpe.rb', line 63 def initialize(args={}) raise ArgumentError unless args.kind_of?(Hash) unless /\/[oah]/.match(args[:part].to_s) || args[:part].nil? raise ArgumentError end @part = args[:part] || "" @vendor = args[:vendor] || "" @product = args[:product] || "" @version = args[:version] || "" @update = args[:update] || "" @edition = args[:edition] || "" @language = args[:language] || "" end |