Skip to content

Commit

Permalink
moved param checks in lines from delegator to delegatee
Browse files Browse the repository at this point in the history
Suggested by bacek++.
  • Loading branch information
Carl Masak committed Mar 21, 2009
1 parent d448f91 commit 79bc4f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 1 addition & 6 deletions src/setting/Any-str.pm
Expand Up @@ -118,13 +118,8 @@ multi sub lines(Str $filename,
:$nl = "\n",
:$chomp = True) {

fail 'Binary mode not supported yet' if $bin;
fail 'Encodings not supported yet' if $enc ne 'Unicode';
fail 'Fancy newlines not supported yet' if $nl ne "\n";
fail 'Lack of chomp not supported yet' if !$chomp;

my $filehandle = open($filename, :r);
return lines($filehandle);
return lines($filehandle, :$bin, :$enc, :$nl, :$chomp);
}

# vim: ft=perl6
12 changes: 11 additions & 1 deletion src/setting/IO.pm
Expand Up @@ -29,7 +29,17 @@ class IO is also {

}

multi sub lines(IO $filehandle) {
multi sub lines(IO $filehandle,
:$bin = False,
:$enc = 'Unicode',
:$nl = "\n",
:$chomp = True) {

fail 'Binary mode not supported yet' if $bin;
fail 'Encodings not supported yet' if $enc ne 'Unicode';
fail 'Fancy newlines not supported yet' if $nl ne "\n";
fail 'Lack of chomp not supported yet' if !$chomp;

return $filehandle.lines();
}

Expand Down

0 comments on commit 79bc4f3

Please sign in to comment.