class CVESchema::CVE::Reference

Represents a reference object within the `“reference_data”` JSON Array.

Constants

REFSOURCES

Attributes

name[R]

Optional reference name.

@return [String, nil]

ref_source[R]

Optional reference source identifier.

@return [:MISC, String, nil]

refsource[R]

Optional reference source identifier.

@return [:MISC, String, nil]

url[R]

Reference URL.

@return [String]

Public Class Methods

from_json(json) click to toggle source

Maps the parsed JSON to a Symbol Hash for {#initialize}.

@param [Hash{String => Object}] json

The parsed JSON.

@return [Hash{Symbol => Object}]

The mapped Symbol Hash.

@api semipublic

# File lib/cve_schema/cve/reference.rb, line 58
def self.from_json(json)
  {
    url:  json['url'],
    name: json['name'],
    refsource: REFSOURCES[json['refsource']]
  }
end
load(json) click to toggle source

Loads the reference from the parsed JSON.

@param [Hash{String => Object}] json

The parsed JSON.

@return [Reference]

@api semipublic

# File lib/cve_schema/cve/reference.rb, line 76
def self.load(json)
  new(**from_json(json))
end
new(url: , name: nil, refsource: nil) click to toggle source

Initializes the reference.

@param [String] url

@param [nil, String] name

@param [nil, :MISC, String] refsource

# File lib/cve_schema/cve/reference.rb, line 41
def initialize(url: , name: nil, refsource: nil)
  @url = url
  @name = name
  @refsource = refsource
end