Class: Vangrail::Watermark::Report
- Inherits:
-
Object
- Object
- Vangrail::Watermark::Report
- 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
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
Instance Method Summary collapse
- #authentic? ⇒ Boolean
-
#coverage ⇒ Object
Share of segments carrying our mark, 0.0 to 1.0.
-
#initialize(segments) ⇒ Report
constructor
A new instance of Report.
- #marked? ⇒ Boolean
- #to_h ⇒ Object
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
#segments ⇒ Object (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
166 167 168 |
# File 'lib/vangrail/watermark.rb', line 166 def authentic? segments.any? { |s| s[:authentic] } end |
#coverage ⇒ Object
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
162 163 164 |
# File 'lib/vangrail/watermark.rb', line 162 def marked? segments.any? { |s| s[:marked] } end |
#to_h ⇒ Object
179 180 181 182 |
# File 'lib/vangrail/watermark.rb', line 179 def to_h { marked: marked?, authentic: authentic?, coverage: coverage, segments: segments.length } end |