Class: Markbridge::Normalizer::Report
- Inherits:
-
Object
- Object
- Markbridge::Normalizer::Report
- Defined in:
- lib/markbridge/normalizer/report.rb
Overview
Tally of the transformations a single #normalize pass applied. Held as a local per call (never on the Normalizer), so a frozen shared instance stays reusable and thread-safe.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize ⇒ Report
constructor
A new instance of Report.
- #record(parent_class, child_class, strategy) ⇒ Object
-
#to_a ⇒ Array<Hash>
One
{parent:, child:, strategy:, count:}row per distinct transformation, e.g.
Constructor Details
#initialize ⇒ Report
Returns a new instance of Report.
9 10 11 |
# File 'lib/markbridge/normalizer/report.rb', line 9 def initialize @counts = Hash.new(0) end |
Instance Method Details
#empty? ⇒ Boolean
21 22 23 |
# File 'lib/markbridge/normalizer/report.rb', line 21 def empty? @counts.empty? end |
#record(parent_class, child_class, strategy) ⇒ Object
16 17 18 |
# File 'lib/markbridge/normalizer/report.rb', line 16 def record(parent_class, child_class, strategy) @counts[[demodulize(parent_class), demodulize(child_class), strategy]] += 1 end |
#to_a ⇒ Array<Hash>
One {parent:, child:, strategy:, count:} row per distinct
transformation, e.g.
{parent: "Url", child: "Image", strategy: :hoist_after, count: 3}.
30 31 32 |
# File 'lib/markbridge/normalizer/report.rb', line 30 def to_a @counts.map { |(parent, child, strategy), count| { parent:, child:, strategy:, count: } } end |