Class: CVESchema::CVE::Affects

Inherits:
Object
  • Object
show all
Defined in:
lib/cve_schema/cve/affects.rb

Overview

Represents the "affects" JSON object.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vendor) ⇒ Affects

Initializes the affects container.

Parameters:



20
21
22
# File 'lib/cve_schema/cve/affects.rb', line 20

def initialize(vendor)
  @vendor = vendor
end

Instance Attribute Details

#vendorArray<Vendor> (readonly) Also known as: vendors

Returns:



11
12
13
# File 'lib/cve_schema/cve/affects.rb', line 11

def vendor
  @vendor
end

Class Method Details

.from_json(json) ⇒ Array<Vendor>

Maps the parsed JSON to an Array of Vendor objects for #initialize.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:



34
35
36
# File 'lib/cve_schema/cve/affects.rb', line 34

def self.from_json(json)
  json['vendor']['vendor_data'].map(&Vendor.method(:load))
end

.load(json) ⇒ Affects

Loads the affects object from parsed JSON.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:

  • (Affects)

    The loaded affects object.



49
50
51
# File 'lib/cve_schema/cve/affects.rb', line 49

def self.load(json)
  new(from_json(json))
end