<commit_before>unit class IO::MiddleMan:ver<1.001001> is IO::Handle;

subset ValidMode     of Str where any <hijack  capture  mute  normal>;
subset OutputMethods of Str where any <print  say  put>;

has            @.data;
has IO::Handle $.handle;
has ValidMode  $.mode is required is rw;

method new (*@, *%) {
    fail 'Cannot instantiate with .new. Please use one of .hijack, '
        ~ '.capture, .mute, or .normal methods.';
}

method hijack  (IO::Handle $handle is rw) {
    $handle = self.bless: :$handle :mode<hijack>;
}
method capture (IO::Handle $handle is rw) {
    $handle = self.bless: :$handle :mode<capture>;
}
method mute    (IO::Handle $handle is rw) {
    $handle = self.bless: :$handle :mode<mute>;
}
method normal  (IO::Handle $handle is rw) {
    $handle = self.bless: :$handle :mode<normal>;
}

method !process (OutputMethods $meth , *@what) returns Bool {
    @what       = @what».gist if $meth eq 'say';
    @what[*-1] ~= $.nl-out    if $meth eq any <put say>;
    given $.mode {
        when 'normal'  { $.handle.print: |@what; }
        when 'mute'    { return True;            }
        when 'capture' | 'hijack' {<commit_msg>Make the @what slurpy a copy<commit_after>unit class IO::MiddleMan:ver<1.001001> is IO::Handle;

subset ValidMode     of Str where any <hijack  capture  mute  normal>;
subset OutputMethods of Str where any <print  say  put>;

has            @.data;
has IO::Handle $.handle;
has ValidMode  $.mode is required is rw;

method new (*@, *%) {
    fail 'Cannot instantiate with .new. Please use one of .hijack, '
        ~ '.capture, .mute, or .normal methods.';
}

method hijack  (IO::Handle $handle is rw) {
    $handle = self.bless: :$handle :mode<hijack>;
}
method capture (IO::Handle $handle is rw) {
    $handle = self.bless: :$handle :mode<capture>;
}
method mute    (IO::Handle $handle is rw) {
    $handle = self.bless: :$handle :mode<mute>;
}
method normal  (IO::Handle $handle is rw) {
    $handle = self.bless: :$handle :mode<normal>;
}

method !process (OutputMethods $meth , *@what is copy) returns Bool {
    @what       = @what».gist if $meth eq 'say';
    @what[*-1] ~= $.nl-out    if $meth eq any <put say>;
    given $.mode {
        when 'normal'  { $.handle.print: |@what; }
        when 'mute'    { return True;            }
        when 'capture' | 'hijack' {
{'fraction_non_alphanumeric': 0.15328467153284672, 'fraction_numerical': 0.006869901245169601, 'mean_word_length': 2.8833333333333333, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '617567', 'n_tokens_mistral': 825, 'n_tokens_neox': 804, 'n_words': 267}