Class: Html2rss::Scoring::Score
- Inherits:
-
Data
- Object
- Data
- Html2rss::Scoring::Score
- Defined in:
- lib/html2rss/scoring/score.rb
Overview
Composite score with quality/junk split and optional typed feature breakdown.
Constant Summary collapse
- EMPTY_BREAKDOWN =
Shared empty feature breakdown for scores without per-feature tallies.
{}.freeze
Instance Attribute Summary collapse
-
#breakdown ⇒ Object
readonly
Returns the value of attribute breakdown.
-
#composite ⇒ Object
readonly
Returns the value of attribute composite.
-
#junk ⇒ Object
readonly
Returns the value of attribute junk.
-
#quality ⇒ Object
readonly
Returns the value of attribute quality.
Class Method Summary collapse
Instance Attribute Details
#breakdown ⇒ Object (readonly)
Returns the value of attribute breakdown
7 8 9 |
# File 'lib/html2rss/scoring/score.rb', line 7 def breakdown @breakdown end |
#composite ⇒ Object (readonly)
Returns the value of attribute composite
7 8 9 |
# File 'lib/html2rss/scoring/score.rb', line 7 def composite @composite end |
#junk ⇒ Object (readonly)
Returns the value of attribute junk
7 8 9 |
# File 'lib/html2rss/scoring/score.rb', line 7 def junk @junk end |
#quality ⇒ Object (readonly)
Returns the value of attribute quality
7 8 9 |
# File 'lib/html2rss/scoring/score.rb', line 7 def quality @quality end |
Class Method Details
.build(composite:, quality: nil, junk: nil, breakdown: nil) ⇒ Score
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/html2rss/scoring/score.rb', line 15 def self.build(composite:, quality: nil, junk: nil, breakdown: nil) raise ArgumentError, 'composite must be Numeric' unless composite.is_a?(Numeric) parts = breakdown.nil? ? Score::EMPTY_BREAKDOWN : breakdown.transform_keys { FeatureId.assert!(_1) }.freeze new( composite: composite.to_f, quality: (quality.nil? ? composite : quality).to_f, junk: (junk || 0).to_f, breakdown: parts ) end |