Class: Detergent::Inspector::Report
- Inherits:
-
Object
- Object
- Detergent::Inspector::Report
- Defined in:
- lib/detergent/inspector.rb
Instance Attribute Summary collapse
-
#best_score ⇒ Object
Returns the value of attribute best_score.
-
#content_root ⇒ Object
Returns the value of attribute content_root.
-
#content_root_size ⇒ Object
Returns the value of attribute content_root_size.
-
#removals ⇒ Object
readonly
Returns the value of attribute removals.
-
#strategy ⇒ Object
Returns the value of attribute strategy.
-
#title ⇒ Object
Returns the value of attribute title.
-
#top_nodes ⇒ Object
Returns the value of attribute top_nodes.
Instance Method Summary collapse
-
#initialize ⇒ Report
constructor
A new instance of Report.
- #located? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Report
Returns a new instance of Report.
25 26 27 28 29 |
# File 'lib/detergent/inspector.rb', line 25 def initialize @removals = { first_pass: [], second_pass: [] } @top_nodes = [] @best_score = 0 end |
Instance Attribute Details
#best_score ⇒ Object
Returns the value of attribute best_score.
22 23 24 |
# File 'lib/detergent/inspector.rb', line 22 def best_score @best_score end |
#content_root ⇒ Object
Returns the value of attribute content_root.
22 23 24 |
# File 'lib/detergent/inspector.rb', line 22 def content_root @content_root end |
#content_root_size ⇒ Object
Returns the value of attribute content_root_size.
22 23 24 |
# File 'lib/detergent/inspector.rb', line 22 def content_root_size @content_root_size end |
#removals ⇒ Object (readonly)
Returns the value of attribute removals.
23 24 25 |
# File 'lib/detergent/inspector.rb', line 23 def removals @removals end |
#strategy ⇒ Object
Returns the value of attribute strategy.
22 23 24 |
# File 'lib/detergent/inspector.rb', line 22 def strategy @strategy end |
#title ⇒ Object
Returns the value of attribute title.
22 23 24 |
# File 'lib/detergent/inspector.rb', line 22 def title @title end |
#top_nodes ⇒ Object
Returns the value of attribute top_nodes.
22 23 24 |
# File 'lib/detergent/inspector.rb', line 22 def top_nodes @top_nodes end |
Instance Method Details
#located? ⇒ Boolean
31 32 33 |
# File 'lib/detergent/inspector.rb', line 31 def located? !content_root.nil? end |
#to_s ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/detergent/inspector.rb', line 35 def to_s lines = ["Detergent #{Detergent::VERSION} debug report"] lines << "Title: #{title.inspect}" lines << verdict lines << "" lines << removal_summary(:first_pass, "First pass (obvious junk)") lines << "" lines << "Top scoring nodes after first pass:" top_nodes.each do |node| lines << format(" %5d %-38s %s", node.score, node.descriptor, node.preview) node.breakdown&.each do |label, points| lines << format(" %+5d %s", points, label) end end lines << "" lines << if located? "Content root: #{content_root} (#{content_root_size} chars of HTML)" else "Content root: (none)" end lines << removal_summary(:second_pass, "Second pass (within content)") lines.join("\n") end |