Class: Nexpose::Tag::Criterion

Inherits:
Criterion show all
Defined in:
lib/nexpose/tag/criteria.rb

Overview

Override of filter criterion to account for proper JSON naming.

Instance Attribute Summary

Attributes inherited from Criterion

#field, #operator, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Criterion

#initialize

Constructor Details

This class inherits a constructor from Nexpose::Criterion

Class Method Details

.parse(json) ⇒ Criterion

Create a Criterion object from a JSON-derived Hash.

Parameters:

  • json (Hash)

    JSON-derived Hash of a Criterion object.

Returns:



18
19
20
# File 'lib/nexpose/tag/criteria.rb', line 18

def self.parse(json)
  new(json['field_name'], json['operator'], json['values'])
end

Instance Method Details

#to_hObject

Convert to Hash, which can be converted to JSON for API calls.



7
8
9
10
11
# File 'lib/nexpose/tag/criteria.rb', line 7

def to_h
  { operator: operator,
    values: Array(value),
    field_name: field }
end