Class: CVESchema::CVE::Reference
- Inherits:
-
Object
- Object
- CVESchema::CVE::Reference
- Defined in:
- lib/cve_schema/cve/reference.rb
Overview
Represents a reference object within the "reference_data"
JSON Array.
Constant Summary collapse
- REFSOURCES =
{ 'MISC' => :MISC }
Instance Attribute Summary collapse
-
#name ⇒ String?
readonly
Optional reference name.
-
#refsource ⇒ :MISC, ...
(also: #ref_source)
readonly
Optional reference source identifier.
-
#url ⇒ String
readonly
Reference URL.
Class Method Summary collapse
-
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
-
.load(json) ⇒ Reference
Loads the reference from the parsed JSON.
Instance Method Summary collapse
-
#initialize(url:, name: nil, refsource: nil) ⇒ Reference
constructor
Initializes the reference.
Constructor Details
#initialize(url:, name: nil, refsource: nil) ⇒ Reference
Initializes the reference.
41 42 43 44 45 |
# File 'lib/cve_schema/cve/reference.rb', line 41 def initialize(url: , name: nil, refsource: nil) @url = url @name = name @refsource = refsource end |
Instance Attribute Details
#name ⇒ String? (readonly)
Optional reference name.
18 19 20 |
# File 'lib/cve_schema/cve/reference.rb', line 18 def name @name end |
#refsource ⇒ :MISC, ... (readonly) Also known as: ref_source
Optional reference source identifier.
28 29 30 |
# File 'lib/cve_schema/cve/reference.rb', line 28 def refsource @refsource end |
#url ⇒ String (readonly)
Reference URL.
13 14 15 |
# File 'lib/cve_schema/cve/reference.rb', line 13 def url @url end |
Class Method Details
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
58 59 60 61 62 63 64 |
# 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) ⇒ Reference
Loads the reference from the parsed JSON.
76 77 78 |
# File 'lib/cve_schema/cve/reference.rb', line 76 def self.load(json) new(**from_json(json)) end |