<commit_before>## $Id$

=head1 TITLE

IO - Perl 6 IO class

=head1 DESCRIPTION

This file implements the IO file handle class.

=head1 Methods

=over 4

=cut

.namespace ['IO']

.sub 'onload' :anon :init :load
    .local pmc p6meta
    p6meta = get_hll_global ['Perl6Object'], '$!P6META'
    p6meta.'new_class'('IO', 'parent'=>'Any', 'attr'=>'$!PIO')
    p6meta.'new_class'('IOIterator', 'parent'=>'Perl6Object', 'attr'=>'$!IO')
.end

=item print

Writes the given list of items to the file.
<commit_msg>[rakudo] Implement lines method on IO objects and export it. Patch courtesy of bacek++.<commit_after>## $Id$

=head1 TITLE

IO - Perl 6 IO class

=head1 DESCRIPTION

This file implements the IO file handle class.

=head1 Methods

=over 4

=cut

.namespace ['IO']

.sub 'onload' :anon :init :load
    .local pmc p6meta
    p6meta = get_hll_global ['Perl6Object'], '$!P6META'
    p6meta.'new_class'('IO', 'parent'=>'Any', 'attr'=>'$!PIO')
    p6meta.'new_class'('IOIterator', 'parent'=>'Perl6Object', 'attr'=>'$!IO')

    $P0 = get_hll_namespace ['IO']
    '!EXPORT'('lines', 'from'=>$P0)
.end


=item lines

our List multi method lines (IO $handle:) is export;

Returns all the lines of a file as a (lazy) List regardless of context. See also slurp.

=cut

.sub 'lines' :method :multi('IO')
    .local pmc PIO, res
    PIO = getattribute self, "$!PIO"
    res = new 'List'

  loop:
    $S0 = PIO.'readline'()
    unless $S0 goto done
    res.'push'($S0)
    goto loop

  done:
    .return (res)
.end


=item print

Writes the given list of items to the file.

{'fraction_non_alphanumeric': 0.15749039692701663, 'fraction_numerical': 0.01856594110115237, 'mean_word_length': 3.6936936936936937, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '1503478', 'n_tokens_mistral': 605, 'n_tokens_neox': 588, 'n_words': 188}