Class: Siftly::FilterResult
- Inherits:
-
Object
- Object
- Siftly::FilterResult
- Defined in:
- lib/siftly/filter_result.rb
Instance Attribute Summary collapse
-
#duration_ms ⇒ Object
readonly
Returns the value of attribute duration_ms.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(filter:, matched:, score:, reason: nil, metadata: {}, error: nil, duration_ms: nil) ⇒ FilterResult
constructor
A new instance of FilterResult.
- #matched? ⇒ Boolean
- #with(filter: @filter, matched: @matched, score: @score, reason: @reason, metadata: @metadata, error: @error, duration_ms: @duration_ms) ⇒ Object
Constructor Details
#initialize(filter:, matched:, score:, reason: nil, metadata: {}, error: nil, duration_ms: nil) ⇒ FilterResult
Returns a new instance of FilterResult.
7 8 9 10 11 12 13 14 15 |
# File 'lib/siftly/filter_result.rb', line 7 def initialize(filter:, matched:, score:, reason: nil, metadata: {}, error: nil, duration_ms: nil) @filter = filter.to_sym @matched = matched @score = score.to_f @reason = reason = .dup @error = error @duration_ms = duration_ms end |
Instance Attribute Details
#duration_ms ⇒ Object (readonly)
Returns the value of attribute duration_ms.
5 6 7 |
# File 'lib/siftly/filter_result.rb', line 5 def duration_ms @duration_ms end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
5 6 7 |
# File 'lib/siftly/filter_result.rb', line 5 def error @error end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
5 6 7 |
# File 'lib/siftly/filter_result.rb', line 5 def filter @filter end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/siftly/filter_result.rb', line 5 def end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
5 6 7 |
# File 'lib/siftly/filter_result.rb', line 5 def reason @reason end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
5 6 7 |
# File 'lib/siftly/filter_result.rb', line 5 def score @score end |
Instance Method Details
#error? ⇒ Boolean
21 22 23 |
# File 'lib/siftly/filter_result.rb', line 21 def error? !error.nil? end |
#matched? ⇒ Boolean
17 18 19 |
# File 'lib/siftly/filter_result.rb', line 17 def matched? @matched end |
#with(filter: @filter, matched: @matched, score: @score, reason: @reason, metadata: @metadata, error: @error, duration_ms: @duration_ms) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/siftly/filter_result.rb', line 25 def with( filter: @filter, matched: @matched, score: @score, reason: @reason, metadata: , error: @error, duration_ms: @duration_ms ) self.class.new( filter: filter, matched: matched, score: score, reason: reason, metadata: , error: error, duration_ms: duration_ms ) end |