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.
288 289 290 291 292 293 294 295 296 |
# File 'lib/nexpose/filter.rb', line 288 def initialize(field, operator, value = '') @field = field.upcase @operator = 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
282 283 284 |
# File 'lib/nexpose/filter.rb', line 282 def field @field end |
#operator ⇒ Object
Search operator. One of Nexpose::Search::Operator
284 285 286 |
# File 'lib/nexpose/filter.rb', line 284 def operator @operator end |
#value ⇒ Object
Search value. A search string or one of Nexpose::Search::Value
286 287 288 |
# File 'lib/nexpose/filter.rb', line 286 def value @value end |
Class Method Details
Instance Method Details
#to_h ⇒ Object
Convert this object into the map format expected by Nexpose.
300 301 302 303 304 |
# File 'lib/nexpose/filter.rb', line 300 def to_h { 'metadata' => { 'fieldName' => field }, 'operator' => operator, 'values' => Array(value) } end |