Class: NVD::JSONFeeds::Schema::CPE::Name

Inherits:
Object
  • Object
show all
Includes:
HasURI
Defined in:
lib/nvd/json_feeds/schema/cpe/name.rb

Overview

Represents the "cpe_name" value.

Instance Attribute Summary collapse

Attributes included from HasURI

#cpe22uri, #cpe23uri

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasURI

included

Constructor Details

#initialize(last_modified_date: nil, **kwargs) ⇒ Name

Initializes the CPE name.

Parameters:

  • last_modified_date (DateTime, nil) (defaults to: nil)


25
26
27
28
29
# File 'lib/nvd/json_feeds/schema/cpe/name.rb', line 25

def initialize(last_modified_date: nil, **kwargs)
  super(**kwargs)

  @last_modified_date = last_modified_date
end

Instance Attribute Details

#last_modified_dateDateTime? (readonly)

Last modified date.

Returns:

  • (DateTime, nil)


18
19
20
# File 'lib/nvd/json_feeds/schema/cpe/name.rb', line 18

def last_modified_date
  @last_modified_date
end

Class Method Details

.from_json(json) ⇒ Hash{Symbol => Object}

Maps the parsed JSON to a Symbol Hash for #initialize.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON Hash.

Returns:

  • (Hash{Symbol => Object})

    The mapped Symbol Hash.



40
41
42
43
44
45
46
47
48
# File 'lib/nvd/json_feeds/schema/cpe/name.rb', line 40

def self.from_json(json)
  {
    **super(json),

    last_modified_date: if (last_modified_date = json['lastModifiedDate'])
                          Timestamp.parse(last_modified_date)
                        end
  }
end

.load(json) ⇒ Name

Loads the CPE name object from the parsed JSON.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON Hash.

Returns:

  • (Name)

    The loaded CPE name object.



59
60
61
# File 'lib/nvd/json_feeds/schema/cpe/name.rb', line 59

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