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.
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.
269 270 271 272 273 274 275 276 |
# File 'lib/nexpose/filter.rb', line 269 def initialize(criteria = [], match = 'AND') if criteria.kind_of?(Array) @criteria = criteria else @criteria = [criteria] end @match = match.upcase end |
Instance Attribute Details
#criteria ⇒ Object
Array of criteria to match against.
267 268 269 |
# File 'lib/nexpose/filter.rb', line 267 def criteria @criteria end |
#match ⇒ Object
Whether to match any or all filters. One of ‘OR’ or ‘AND’.
265 266 267 |
# File 'lib/nexpose/filter.rb', line 265 def match @match end |
Class Method Details
Instance Method Details
#_to_payload ⇒ Object
Generate the payload needed for a POST request for Asset Filter.
291 292 293 294 295 296 297 298 |
# File 'lib/nexpose/filter.rb', line 291 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.
285 286 287 |
# File 'lib/nexpose/filter.rb', line 285 def to_json JSON.generate(to_map) end |
#to_map ⇒ Object
278 279 280 281 |
# File 'lib/nexpose/filter.rb', line 278 def to_map { 'operator' => @match, 'criteria' => @criteria.map { |c| c.to_map } } end |