Class: Siftly::Result

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spam:, score:, filter_results:, reasons:, attribute:, value_preview:, threshold:, aggregator:) ⇒ Result

Returns a new instance of Result.



7
8
9
10
11
12
13
14
15
16
# File 'lib/siftly/result.rb', line 7

def initialize(spam:, score:, filter_results:, reasons:, attribute:, value_preview:, threshold:, aggregator:)
  @spam = spam
  @score = score.to_f
  @filter_results = filter_results.dup.freeze
  @reasons = reasons.compact.freeze
  @attribute = attribute
  @value_preview = value_preview
  @threshold = threshold
  @aggregator = aggregator
end

Instance Attribute Details

#aggregatorObject (readonly)

Returns the value of attribute aggregator.



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

def aggregator
  @aggregator
end

#attributeObject (readonly)

Returns the value of attribute attribute.



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

def attribute
  @attribute
end

#filter_resultsObject (readonly)

Returns the value of attribute filter_results.



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

def filter_results
  @filter_results
end

#reasonsObject (readonly)

Returns the value of attribute reasons.



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

def reasons
  @reasons
end

#scoreObject (readonly)

Returns the value of attribute score.



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

def score
  @score
end

#thresholdObject (readonly)

Returns the value of attribute threshold.



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

def threshold
  @threshold
end

#value_previewObject (readonly)

Returns the value of attribute value_preview.



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

def value_preview
  @value_preview
end

Instance Method Details

#errorsObject



26
27
28
# File 'lib/siftly/result.rb', line 26

def errors
  filter_results.select(&:error?)
end

#matchesObject



22
23
24
# File 'lib/siftly/result.rb', line 22

def matches
  filter_results.select(&:matched?)
end

#spam?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/siftly/result.rb', line 18

def spam?
  @spam
end