Class: CVESchema::CVE::Source
- Inherits:
-
Object
- Object
- CVESchema::CVE::Source
- Defined in:
- lib/cve_schema/cve/source.rb
Overview
Represents the "source"
JSON object.
Constant Summary collapse
- DISCOVERY =
{ 'INTERNAL' => :INTERNAL, 'EXTERNAL' => :EXTERNAL, 'USER' => :USER, 'UNKNOWN' => :UNKNOWN }
Instance Attribute Summary collapse
- #advisory ⇒ String? readonly
- #defect ⇒ Array<String>? readonly
- #discovery ⇒ :INTERNAL, ... readonly
Class Method Summary collapse
-
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
-
.load(json) ⇒ Source
Loads the source from the parsed JSON.
Instance Method Summary collapse
-
#initialize(discovery:, defect: nil, advisory: nil) ⇒ Source
constructor
Initializes the source object.
Constructor Details
#initialize(discovery:, defect: nil, advisory: nil) ⇒ Source
Initializes the source object.
35 36 37 38 39 |
# File 'lib/cve_schema/cve/source.rb', line 35 def initialize(discovery: , defect: nil, advisory: nil) @defect = defect @discovery = discovery @advisory = advisory end |
Instance Attribute Details
#advisory ⇒ String? (readonly)
24 25 26 |
# File 'lib/cve_schema/cve/source.rb', line 24 def advisory @advisory end |
#defect ⇒ Array<String>? (readonly)
11 12 13 |
# File 'lib/cve_schema/cve/source.rb', line 11 def defect @defect end |
#discovery ⇒ :INTERNAL, ... (readonly)
21 22 23 |
# File 'lib/cve_schema/cve/source.rb', line 21 def discovery @discovery end |
Class Method Details
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
50 51 52 53 54 55 56 |
# File 'lib/cve_schema/cve/source.rb', line 50 def self.from_json(json) { defect: json['defect'], discovery: DISCOVERY[json['discovery']], advisory: json['advisory'] } end |
.load(json) ⇒ Source
Loads the source from the parsed JSON.
69 70 71 |
# File 'lib/cve_schema/cve/source.rb', line 69 def self.load(json) new(**from_json(json)) end |