Class: Insika::ToolUsageReport::Report
- Inherits:
-
Data
- Object
- Data
- Insika::ToolUsageReport::Report
- Defined in:
- lib/insika/tool_usage_report.rb
Instance Attribute Summary collapse
-
#agents ⇒ Object
readonly
Returns the value of attribute agents.
-
#days ⇒ Object
readonly
Returns the value of attribute days.
-
#generated_at ⇒ Object
readonly
Returns the value of attribute generated_at.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #to_h ⇒ Object
-
#to_s ⇒ Object
Human report, grouped by agent.
Instance Attribute Details
#agents ⇒ Object (readonly)
Returns the value of attribute agents
36 37 38 |
# File 'lib/insika/tool_usage_report.rb', line 36 def agents @agents end |
#days ⇒ Object (readonly)
Returns the value of attribute days
36 37 38 |
# File 'lib/insika/tool_usage_report.rb', line 36 def days @days end |
#generated_at ⇒ Object (readonly)
Returns the value of attribute generated_at
36 37 38 |
# File 'lib/insika/tool_usage_report.rb', line 36 def generated_at @generated_at end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows
36 37 38 |
# File 'lib/insika/tool_usage_report.rb', line 36 def rows @rows end |
Instance Method Details
#to_h ⇒ Object
37 38 39 40 |
# File 'lib/insika/tool_usage_report.rb', line 37 def to_h { "generated_at" => generated_at, "days" => days, "agents" => agents, "rows" => rows.map(&:to_h) } end |
#to_s ⇒ Object
Human report, grouped by agent. Silent agents still print their header — "nothing flagged" is a result, not an omission.
44 45 46 47 48 49 50 51 52 |
# File 'lib/insika/tool_usage_report.rb', line 44 def to_s lines = ["tool usage — last #{days} day(s), generated #{generated_at}"] agents.each do |agent| mine = rows.select { |r| r.agent == agent } lines << "" << "#{agent}: #{mine.empty? ? 'nothing flagged' : "#{mine.length} finding(s)"}" mine.each { |r| lines << format(" %-13s %s — %s", r.kind, r.tool, r.detail) } end lines.join("\n") end |