Class: NVD::JSONFeeds::Schema::Configurations::Node
- Inherits:
-
Object
- Object
- NVD::JSONFeeds::Schema::Configurations::Node
- Defined in:
- lib/nvd/json_feeds/schema/configurations/node.rb
Overview
Represents a value within "nodes"
.
Constant Summary collapse
- OPERATORS =
{ 'OR' => :OR, 'AND' => :AND }
Instance Attribute Summary collapse
- #children ⇒ Array<Node> readonly
- #cpe_match ⇒ Array<CPE::Match> readonly
- #negate ⇒ Boolean? readonly
- #operator ⇒ :OR, ... readonly
Class Method Summary collapse
-
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
-
.load(json) ⇒ Node
Loads the node object from the parsed JSON.
Instance Method Summary collapse
-
#initialize(operator: nil, negate: nil, children: [], cpe_match: []) ⇒ Node
constructor
Initializes the node.
-
#negate? ⇒ Boolean
Determines if #negate is
true
.
Constructor Details
#initialize(operator: nil, negate: nil, children: [], cpe_match: []) ⇒ Node
Initializes the node.
40 41 42 43 44 45 46 |
# 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 |
Instance Attribute Details
#children ⇒ Array<Node> (readonly)
24 25 26 |
# File 'lib/nvd/json_feeds/schema/configurations/node.rb', line 24 def children @children end |
#cpe_match ⇒ Array<CPE::Match> (readonly)
27 28 29 |
# File 'lib/nvd/json_feeds/schema/configurations/node.rb', line 27 def cpe_match @cpe_match end |
#negate ⇒ Boolean? (readonly)
21 22 23 |
# File 'lib/nvd/json_feeds/schema/configurations/node.rb', line 21 def negate @negate end |
#operator ⇒ :OR, ... (readonly)
18 19 20 |
# File 'lib/nvd/json_feeds/schema/configurations/node.rb', line 18 def operator @operator end |
Class Method Details
.from_json(json) ⇒ Hash{Symbol => Object}
Maps the parsed JSON to a Symbol Hash for #initialize.
68 69 70 71 72 73 74 75 76 77 78 |
# 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) ⇒ Node
Loads the node object from the parsed JSON.
89 90 91 |
# File 'lib/nvd/json_feeds/schema/configurations/node.rb', line 89 def self.load(json) new(**from_json(json)) end |
Instance Method Details
#negate? ⇒ Boolean
Determines if #negate is true
.
53 54 55 |
# File 'lib/nvd/json_feeds/schema/configurations/node.rb', line 53 def negate? @negate == true end |