Class: Vangrail::Watermark::Report

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

Overview

What verify found. Plain readers rather than predicates on a hash, because a caller reporting a posture reads all three.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(segments) ⇒ Report

Returns a new instance of Report.



158
159
160
# File 'lib/vangrail/watermark.rb', line 158

def initialize(segments)
  @segments = segments.freeze
end

Instance Attribute Details

#segmentsObject (readonly)

Returns the value of attribute segments.



156
157
158
# File 'lib/vangrail/watermark.rb', line 156

def segments
  @segments
end

Instance Method Details

#authentic?Boolean

Returns:

  • (Boolean)


166
167
168
# File 'lib/vangrail/watermark.rb', line 166

def authentic?
  segments.any? { |s| s[:authentic] }
end

#coverageObject

Share of segments carrying our mark, 0.0 to 1.0. A quote of one paragraph out of six scores low and is still ours; the number is for deciding whether a whole answer or a fragment is in front of you.



173
174
175
176
177
# File 'lib/vangrail/watermark.rb', line 173

def coverage
  return 0.0 if segments.empty?

  segments.count { |s| s[:authentic] }.fdiv(segments.length)
end

#marked?Boolean

Returns:

  • (Boolean)


162
163
164
# File 'lib/vangrail/watermark.rb', line 162

def marked?
  segments.any? { |s| s[:marked] }
end

#to_hObject



179
180
181
182
# File 'lib/vangrail/watermark.rb', line 179

def to_h
  { marked: marked?, authentic: authentic?, coverage: coverage,
    segments: segments.length }
end