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.
289 290 291 292 293 294 295 296 |
# File 'lib/nexpose/filter.rb', line 289 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
283 284 285 |
# File 'lib/nexpose/filter.rb', line 283 def field @field end |
#operator ⇒ Object
Search operator. One of Nexpose::Search::Operator
285 286 287 |
# File 'lib/nexpose/filter.rb', line 285 def operator @operator end |
#value ⇒ Object
Search value. A search string or one of Nexpose::Search::Value
287 288 289 |
# File 'lib/nexpose/filter.rb', line 287 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 |