Class: NVD::JSONFeeds::Schema::Configurations

Inherits:
Object
  • Object
show all
Includes:
HasDataVersion
Defined in:
lib/nvd/json_feeds/schema/configurations.rb,
lib/nvd/json_feeds/schema/configurations/node.rb

Overview

Represents the "configurations" value.

Defined Under Namespace

Classes: Node

Constant Summary

Constants included from HasDataVersion

HasDataVersion::DATA_VERSIONS

Instance Attribute Summary collapse

Attributes included from HasDataVersion

#data_version

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasDataVersion

included

Constructor Details

#initialize(nodes: [], **kwargs) ⇒ Configurations

Initializes the configuration.

Parameters:

  • nodes (Array<Node>) (defaults to: [])


24
25
26
27
28
# File 'lib/nvd/json_feeds/schema/configurations.rb', line 24

def initialize(nodes: [], **kwargs)
  super(**kwargs)

  @nodes = nodes
end

Instance Attribute Details

#nodesArray<Node> (readonly)

The nodes of the configuration.

Returns:



17
18
19
# File 'lib/nvd/json_feeds/schema/configurations.rb', line 17

def nodes
  @nodes
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})

Returns:

  • (Hash{Symbol => Object})


37
38
39
40
41
42
43
# File 'lib/nvd/json_feeds/schema/configurations.rb', line 37

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

    nodes: Array(json['nodes']).map(&Node.method(:load))
  }
end

.load(json) ⇒ Cojnfiguration

Loads the configuration from the parsed JSON.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:

  • (Cojnfiguration)

    The loaded configuration object.



54
55
56
# File 'lib/nvd/json_feeds/schema/configurations.rb', line 54

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