Class: CVESchema::CVE::Vendor
- Inherits:
-
Object
- Object
- CVESchema::CVE::Vendor
- Defined in:
- lib/cve_schema/cve/vendor.rb
Overview
Represents an element within the "vendor_data"
JSON Array.
Instance Attribute Summary collapse
- #product ⇒ Array<Product> readonly
- #vendor_name ⇒ String readonly
Class Method Summary collapse
-
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
-
.load(json) ⇒ Vendor
Loads the vendor object from the parsed JSON.
Instance Method Summary collapse
-
#initialize(vendor_name:, product:) ⇒ Vendor
constructor
Initializes the vendor object.
-
#na? ⇒ Boolean
Determines if the #vendor_name is
n/a
. -
#to_s ⇒ String
Converts the vendor object to a String.
Constructor Details
#initialize(vendor_name:, product:) ⇒ Vendor
Initializes the vendor object.
24 25 26 27 |
# File 'lib/cve_schema/cve/vendor.rb', line 24 def initialize(vendor_name: , product: ) @vendor_name = vendor_name @product = product end |
Instance Attribute Details
#product ⇒ Array<Product> (readonly)
15 16 17 |
# File 'lib/cve_schema/cve/vendor.rb', line 15 def product @product end |
#vendor_name ⇒ String (readonly)
12 13 14 |
# File 'lib/cve_schema/cve/vendor.rb', line 12 def vendor_name @vendor_name end |
Class Method Details
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
59 60 61 62 63 64 |
# File 'lib/cve_schema/cve/vendor.rb', line 59 def self.from_json(json) { vendor_name: json['vendor_name'], product: json['product']['product_data'].map(&Product.method(:load)) } end |
.load(json) ⇒ Vendor
Loads the vendor object from the parsed JSON.
77 78 79 |
# File 'lib/cve_schema/cve/vendor.rb', line 77 def self.load(json) new(**from_json(json)) end |
Instance Method Details
#na? ⇒ Boolean
Determines if the #vendor_name is n/a
.
34 35 36 |
# File 'lib/cve_schema/cve/vendor.rb', line 34 def na? @vendor_name == NA end |
#to_s ⇒ String
Converts the vendor object to a String.
44 45 46 |
# File 'lib/cve_schema/cve/vendor.rb', line 44 def to_s @vendor_name end |