Module: Smyte::LabelReporter
- Included in:
- Classification, Notification::Item
- Defined in:
- lib/smyte/label_reporter.rb
Instance Method Summary collapse
-
#action ⇒ Object
returns :block, :review, :allow, :unknown.
- #label_actions ⇒ Object
- #label_report ⇒ Object
- #labels ⇒ Object
- #reset_labels ⇒ Object
Instance Method Details
#action ⇒ Object
returns :block, :review, :allow, :unknown
7 8 9 |
# File 'lib/smyte/label_reporter.rb', line 7 def action @action ||= calculate_action end |
#label_actions ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/smyte/label_reporter.rb', line 15 def label_actions return @label_actions if @label_actions found = Hash.new { |hash, key| hash[key] = [] } labels.each do |label| found[label.action] << label end @label_actions = found end |
#label_report ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/smyte/label_reporter.rb', line 25 def label_report return @label_report if @label_report out = [] labels.each do |label| case label.action when :block, :review out << label.name end end @label_report = out end |
#labels ⇒ Object
11 12 13 |
# File 'lib/smyte/label_reporter.rb', line 11 def labels @labels ||= parse_labels end |
#reset_labels ⇒ Object
39 40 41 42 43 44 |
# File 'lib/smyte/label_reporter.rb', line 39 def reset_labels remove_instance_variable(:@label_report) if defined?(@label_report) remove_instance_variable(:@label_actions) if defined?(@label_actions) remove_instance_variable(:@labels) if defined?(@labels) remove_instance_variable(:@action) if defined?(@action) end |