Class: Siftly::FilterResult

Inherits:
Object
  • Object
show all
Defined in:
lib/siftly/filter_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_msObject (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

#errorObject (readonly)

Returns the value of attribute error.



5
6
7
# File 'lib/siftly/filter_result.rb', line 5

def error
  @error
end

#filterObject (readonly)

Returns the value of attribute filter.



5
6
7
# File 'lib/siftly/filter_result.rb', line 5

def filter
  @filter
end

#metadataObject (readonly)

Returns the value of attribute metadata.



5
6
7
# File 'lib/siftly/filter_result.rb', line 5

def 
  
end

#reasonObject (readonly)

Returns the value of attribute reason.



5
6
7
# File 'lib/siftly/filter_result.rb', line 5

def reason
  @reason
end

#scoreObject (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

Returns:

  • (Boolean)


21
22
23
# File 'lib/siftly/filter_result.rb', line 21

def error?
  !error.nil?
end

#matched?Boolean

Returns:

  • (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