Class: NVD::JSONFeeds::Schema::Impact
- Inherits:
-
Object
- Object
- NVD::JSONFeeds::Schema::Impact
- Defined in:
- lib/nvd/json_feeds/schema/impact.rb,
lib/nvd/json_feeds/schema/impact/base_metric_v2.rb,
lib/nvd/json_feeds/schema/impact/base_metric_v3.rb
Overview
Represents the "impact"
value.
Defined Under Namespace
Classes: BaseMetricV2, BaseMetricV3
Instance Attribute Summary collapse
-
#base_metric_v2 ⇒ BaseMetricV2?
readonly
The base metric V2.
-
#base_metric_v3 ⇒ BaseMetricV3?
readonly
The base metric V3.
Class Method Summary collapse
-
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
-
.load(json) ⇒ Impact
Loads the impact object from the parsed JSON.
Instance Method Summary collapse
-
#initialize(base_metric_v3: nil, base_metric_v2: nil) ⇒ Impact
constructor
Initializes the impact object.
Constructor Details
#initialize(base_metric_v3: nil, base_metric_v2: nil) ⇒ Impact
Initializes the impact object.
31 32 33 34 |
# File 'lib/nvd/json_feeds/schema/impact.rb', line 31 def initialize(base_metric_v3: nil, base_metric_v2: nil) @base_metric_v3 = base_metric_v3 @base_metric_v2 = base_metric_v2 end |
Instance Attribute Details
#base_metric_v2 ⇒ BaseMetricV2? (readonly)
The base metric V2.
20 21 22 |
# File 'lib/nvd/json_feeds/schema/impact.rb', line 20 def base_metric_v2 @base_metric_v2 end |
#base_metric_v3 ⇒ BaseMetricV3? (readonly)
The base metric V3.
15 16 17 |
# File 'lib/nvd/json_feeds/schema/impact.rb', line 15 def base_metric_v3 @base_metric_v3 end |
Class Method Details
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/nvd/json_feeds/schema/impact.rb', line 45 def self.from_json(json) { base_metric_v3: if (base_metric_v3 = json['baseMetricV3']) BaseMetricV3.load(base_metric_v3) end, base_metric_v2: if (base_metric_v2 = json['baseMetricV2']) BaseMetricV2.load(base_metric_v2) end } end |
.load(json) ⇒ Impact
Loads the impact object from the parsed JSON.
66 67 68 |
# File 'lib/nvd/json_feeds/schema/impact.rb', line 66 def self.load(json) new(**from_json(json)) end |