class CVESchema::CVE::Version
Represents an element within the `“version_data”` JSON Array.
Constants
- VERSION_AFFECTED
Attributes
@return [nil, :'=', :'<', :'>', :'<=', , :'>=', :'!', :'!<', :'!>', :'!<=', :'!>=', :'?', :'?<', :'?>', :'?<=', :'?>=']
@return [nil, String]
@return [String]
Public Class Methods
Maps the parsed JSON to a Symbol Hash for {#initialize}.
@param [Hash{String => String}] json
The parsed JSON.
@return [Hash{Symbol => Object}]
The mapped Symbol Hash.
@raise [UnknownJSONValue]
The `"version_affected"` JSON value was unknown.
@api semipublic
# File lib/cve_schema/cve/version.rb, line 70 def self.from_json(json) { version_affected: if (version_affected = json['version_affected']) VERSION_AFFECTED.fetch(version_affected) do raise UnknownJSONValue.new('version_affected',version_affected) end end, version_name: json['version_name'], version_value: json['version_value'] } end
Loads the version object from parsed JSON.
@param [Hash{String => String}] json
The parsed JSON.
@return [Version]
The loaded version object.
@raise [UnknownJSONValue]
The `"version_affected"` JSON value was unknown.
@api semipublic
# File lib/cve_schema/cve/version.rb, line 97 def self.load(json) new(**from_json(json)) end
Initializes the version.
@param [String] version_value
@param [String, nil] version_name
@param [nil, :'=', :'<', :'>', :'<=', , :'>=', :'!', :'!<', :'!>', :'!<=', :'!>=', :'?', :'?<', :'?>', :'?<=', :'?>='] version_affected
The version comparison operator. See {VERSION_AFFECTED}.
# File lib/cve_schema/cve/version.rb, line 50 def initialize(version_value: , version_name: nil, version_affected: nil) @version_value = version_value @version_name = version_name @version_affected = version_affected end
Public Instance Methods
Determines if the {#version_value} is `n/a`.
@return [Boolean]
# File lib/cve_schema/cve/version.rb, line 106 def na? @version_value == NA end
Converts the version into a String.
@return [String]
The {#version_value} and additionally the {#version_affected}.
# File lib/cve_schema/cve/version.rb, line 116 def to_s if @version_affected "#{@version_affected} #{@version_value}" else @version_value end end