diff options
| author | Paul Buetow <paul@buetow.org> | 2023-03-29 23:37:19 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-03-29 23:37:19 +0300 |
| commit | fc4425721294e40c25ef6cc2c980dd661a061d88 (patch) | |
| tree | b892810b4f12c7e617fb3cca734dd7f77fa2aecc /guprecords.raku | |
| parent | 88e42a0f1de8cd541a3f419aa4bed02e594d5383 (diff) | |
refactor to use gather/take rather than push @ret, ...
Diffstat (limited to 'guprecords.raku')
| -rw-r--r-- | guprecords.raku | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/guprecords.raku b/guprecords.raku index fa22501..d7f925e 100644 --- a/guprecords.raku +++ b/guprecords.raku @@ -108,29 +108,28 @@ class Reporter { has Metric $.metric is required; method report returns Str { - my @ret; - push @ret, "{self!output-header}Top {$.limit} {$.metric}'s by {$.category}:\n\n"; - - with self!table -> (@table, %size) { - my \format = '|' ~ join '|', - " %{%size<count>}s ", " %{%size<name>}s ", " %{%size<value>}s ", "\n"; - my \border = '+' ~ join '+', - '-' x (2+%size<count>), '-' x (2+%size<name>), '-' x (2+%size<value>), "\n"; - - push @ret, self!output-block; - push @ret, border; - push @ret, sprintf format, 'Pos', $.category, $.metric; - push @ret, border; - - for @table -> \position, \name, \value { - push @ret, sprintf format, position, name, value; + join '', gather { + take "{self!output-header}Top {$.limit} {$.metric}'s by {$.category}:\n\n"; + + with self!table -> (@table, %size) { + my \format = '|' ~ join '|', + " %{%size<count>}s ", " %{%size<name>}s ", " %{%size<value>}s ", "\n"; + my \border = '+' ~ join '+', + '-' x (2+%size<count>), '-' x (2+%size<name>), '-' x (2+%size<value>), "\n"; + + take self!output-block; + take border; + take sprintf format, 'Pos', $.category, $.metric; + take border; + + for @table -> \position, \name, \value { + take sprintf format, position, name, value; + } + + take border; + take self!output-block; } - - push @ret, border; - push @ret, self!output-block; } - - return @ret.join(''); } method !table returns List { |
