From 0e895091e169561f9dce914c23fd6d15c002a149 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 27 Mar 2023 20:08:53 +0300 Subject: remove of useless abstraction --- guprecords.raku | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'guprecords.raku') diff --git a/guprecords.raku b/guprecords.raku index 64816a4..ca31eed 100644 --- a/guprecords.raku +++ b/guprecords.raku @@ -94,27 +94,16 @@ class Aggregator { } } -role OutputFormatter { +class Reporter { has OutputFormat $.output-format is required; + has Natural $.limit is required; has Natural $.header-indent = 1; - - method output-header { - ($.output-format ~~ any (Markdown, Gemtext)) ?? '#' x $.header-indent ~ ' ' !! '' - } - - method output-block { - ($.output-format ~~ any (Markdown, Gemtext)) ?? '```' !! '' - } -} - -class Reporter does OutputFormatter { has Category $.category = Host; has Metric $.metric is required; - has Natural $.limit is required; has Hash %.aggregates; method report { - say "{self.output-header}Top {$.limit} {$.metric}'s by {$.category}:\n"; + say "{self!output-header}Top {$.limit} {$.metric}'s by {$.category}:\n"; with self!table -> (@table, %size) { my Str \format = '|' ~ join '|', @@ -122,7 +111,7 @@ class Reporter does OutputFormatter { my Str \border = '+' ~ join '+', '-' x (2+%size), '-' x (2+%size), '-' x (2+%size), "\n"; - say self.output-block; + say self!output-block; print border; printf format, 'Pos', $.category, $.metric; print border; @@ -132,7 +121,7 @@ class Reporter does OutputFormatter { } print border; - say self.output-block; + say self!output-block; } } @@ -161,6 +150,14 @@ class Reporter does OutputFormatter { return @table, %size; } + method !output-header { + ($.output-format ~~ any (Markdown, Gemtext)) ?? '#' x $.header-indent ~ ' ' !! '' + } + + method !output-block { + ($.output-format ~~ any (Markdown, Gemtext)) ?? '```' !! '' + } + multi method sort-by(Uptime) { self.sort-by: *.uptime } multi method sort-by(Boots) { self.sort-by: *.boots } multi method sort-by(MetaScore) { self.sort-by: *.meta-score } -- cgit v1.2.3