Class: Nexpose::Criteria
- Inherits:
-
Object
- Object
- Nexpose::Criteria
- Defined in:
- lib/nexpose/filter.rb
Overview
Join search criteria for an asset filter search or dynamic asset group.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#criteria ⇒ Object
Array of criteria to match against.
-
#match ⇒ Object
Whether to match any or all filters.
Class Method Summary collapse
Instance Method Summary collapse
-
#_to_payload ⇒ Object
Generate the payload needed for a POST request for Asset Filter.
-
#initialize(criteria = [], match = 'AND') ⇒ Criteria
constructor
A new instance of Criteria.
-
#to_json ⇒ Object
Convert this object into the format expected by Nexpose.
- #to_map ⇒ Object
Constructor Details
#initialize(criteria = [], match = 'AND') ⇒ Criteria
Returns a new instance of Criteria.
300 301 302 303 |
# File 'lib/nexpose/filter.rb', line 300 def initialize(criteria = [], match = 'AND') @criteria = Array(criteria) @match = match.upcase end |
Instance Attribute Details
#criteria ⇒ Object
Array of criteria to match against.
298 299 300 |
# File 'lib/nexpose/filter.rb', line 298 def criteria @criteria end |
#match ⇒ Object
Whether to match any or all filters. One of ‘OR’ or ‘AND’.
296 297 298 |
# File 'lib/nexpose/filter.rb', line 296 def match @match end |
Class Method Details
Instance Method Details
#_to_payload ⇒ Object
Generate the payload needed for a POST request for Asset Filter.
318 319 320 321 322 323 324 325 |
# File 'lib/nexpose/filter.rb', line 318 def _to_payload { 'dir' => -1, 'results' => -1, 'sort' => 'assetIP', 'startIndex' => -1, 'table-id' => 'assetfilter', 'searchCriteria' => to_json } end |
#to_json ⇒ Object
Convert this object into the format expected by Nexpose.
312 313 314 |
# File 'lib/nexpose/filter.rb', line 312 def to_json JSON.generate(to_map) end |
#to_map ⇒ Object
305 306 307 308 |
# File 'lib/nexpose/filter.rb', line 305 def to_map { 'operator' => @match, 'criteria' => @criteria.map { |c| c.to_map } } end |