Class: Nexpose::Criterion
- Inherits:
-
Object
- Object
- Nexpose::Criterion
- Defined in:
- lib/nexpose/filter.rb
Overview
Individual search criterion.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#field ⇒ Object
Search field.
-
#operator ⇒ Object
Search operator.
-
#value ⇒ Object
Search value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(field, operator, value = '') ⇒ Criterion
constructor
A new instance of Criterion.
-
#to_h ⇒ Object
Convert this object into the map format expected by Nexpose.
Constructor Details
#initialize(field, operator, value = '') ⇒ Criterion
Returns a new instance of Criterion.
290 291 292 293 294 295 296 297 |
# File 'lib/nexpose/filter.rb', line 290 def initialize(field, operator, value = '') @field, @operator = field.upcase, operator.upcase if value.is_a? Array @value = value.map(&:to_s) else @value = value.to_s end end |
Instance Attribute Details
#field ⇒ Object
Search field. One of Nexpose::Search::Field
284 285 286 |
# File 'lib/nexpose/filter.rb', line 284 def field @field end |
#operator ⇒ Object
Search operator. One of Nexpose::Search::Operator
286 287 288 |
# File 'lib/nexpose/filter.rb', line 286 def operator @operator end |
#value ⇒ Object
Search value. A search string or one of Nexpose::Search::Value
288 289 290 |
# File 'lib/nexpose/filter.rb', line 288 def value @value end |
Class Method Details
Instance Method Details
#to_h ⇒ Object
Convert this object into the map format expected by Nexpose.
301 302 303 304 305 |
# File 'lib/nexpose/filter.rb', line 301 def to_h { 'metadata' => { 'fieldName' => field }, 'operator' => operator, 'values' => Array(value) } end |