Class: Vangrail::Triage

Inherits:
Struct
  • Object
show all
Defined in:
lib/vangrail/assessor.rb

Overview

What triage returns. The ranking is the product: a caller that wants the old behaviour reads kept, and one that wants to put the doubtful pages last reads them in order.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#judged ⇒ Object

Returns the value of attribute judged

Returns:

  • (Object) —

    the current value of judged



224
225
226
# File 'lib/vangrail/assessor.rb', line 224

def judged
  @judged
end

Instance Method Details

#certain? ⇒ Boolean

Returns:

  • (Boolean)


237
238
239
# File 'lib/vangrail/assessor.rb', line 237

def certain?
  judged.all? { |row| row[:judgement].certain? }
end

#dropped ⇒ Object



225
226
227
# File 'lib/vangrail/assessor.rb', line 225

def dropped
  judged.select { |row| row[:judgement].block? }
end

#kept ⇒ Object



233
234
235
# File 'lib/vangrail/assessor.rb', line 233

def kept
  judged.reject { |row| row[:judgement].block? }.reverse.map { |row| row[:document] }
end

#review ⇒ Object



229
230
231
# File 'lib/vangrail/assessor.rb', line 229

def review
  judged.select { |row| row[:judgement].review? }
end

#to_h ⇒ Object



241
242
243
244
245
246
247
248
# File 'lib/vangrail/assessor.rb', line 241

def to_h
  {
    'kept' => kept.size,
    'review' => review.size,
    'dropped' => dropped.map { |row| row[:judgement].to_h },
    'certain' => certain?,
  }
end