class NVD::JSONFeeds::Schema::Configurations::Node

Represents a value within `“nodes”`.

Constants

OPERATORS

Attributes

children[R]

@return [Array<Node>]

cpe_match[R]

@return [Array<CPE::Match>]

negate[R]

@return [Boolean, nil]

operator[R]

@return [:OR, :AND, String]

Public Class Methods

from_json(json) click to toggle source

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

@param [Hash{String => Object}] json

The parsed JSON.

@return [Hash{Symbol => Object}]

The Symbol Hash.

@see csrc.nist.gov/schema/nvd/feed/1.1-Beta/cvss-v2.0_beta.json

# File lib/nvd/json_feeds/schema/configurations/node.rb, line 68
def self.from_json(json)
  {
    operator: if (operator = json['operator'])
                OPERATORS.fetch(operator,operator)
              end,
    negate:   json['negate'],

    children:  Array(json['children']).map(&method(:load)),
    cpe_match: Array(json['cpe_match']).map(&CPE::Match.method(:load))
  }
end
load(json) click to toggle source

Loads the node object from the parsed JSON.

@param [Hash{String => Object}] json

The parsed JSON.

@return [Node]

The node object.
# File lib/nvd/json_feeds/schema/configurations/node.rb, line 89
def self.load(json)
  new(**from_json(json))
end
new(operator: nil, negate: nil, children: [], cpe_match: []) click to toggle source

Initializes the node.

@param [:OR, :AND, String] operator

@param [Boolean, nil] negate

@param [Array<Node>] children

@param [Array<CPE::Match>] cpe_match

# File lib/nvd/json_feeds/schema/configurations/node.rb, line 40
def initialize(operator: nil, negate: nil, children: [], cpe_match: [])
  @operator = operator
  @negate   = negate

  @children = children
  @cpe_match = cpe_match
end

Public Instance Methods

negate?() click to toggle source

Determines if {#negate} is `true`.

@return [Boolean]

# File lib/nvd/json_feeds/schema/configurations/node.rb, line 53
def negate?
  @negate == true
end