diff options
| author | Paul Buetow <paul@buetow.org> | 2023-03-27 20:08:53 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-03-27 20:08:53 +0300 |
| commit | 0e895091e169561f9dce914c23fd6d15c002a149 (patch) | |
| tree | f3d11b3f7118d97922c58eedcdef5588d2fa6860 | |
| parent | b7f807f2cacca287bb654062527fa5b5c194d190 (diff) | |
remove of useless abstraction
| -rw-r--r-- | guprecords.raku | 29 |
1 files changed, 13 insertions, 16 deletions
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<count>), '-' x (2+%size<name>), '-' x (2+%size<value>), "\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 } |
