Skip to content

Commit

Permalink
use multi method
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Weidenbaum committed Oct 12, 2017
1 parent 7de89dd commit e6e6574
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lib/File/Presence.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ constant $VERSION = v0.0.3;

subset PresenceHash of Hash where { .keys.sort ~~ <d e f r w x> }

method show(Str:D $file where *.so --> PresenceHash:D)
multi method show(Str:D $file where *.so && *.IO.e.so --> PresenceHash:D)
{
my Bool:D $e = $file.IO.e;
my Bool:D $e = True;
my Bool:D $d = $file.IO.d;
my Bool:D $f = $file.IO.f;
my Bool:D $r = $file.IO.r;
my Bool:D $w = $file.IO.w;
my Bool:D $x = $file.IO.x;
my PresenceHash:D $p = %(:$d, :$e, :$f, :$r, :$w, :$x);
}

multi method show(Str:D $file where *.so --> PresenceHash:D)
{
my Bool:D $e = False;
my Bool:D $d = False;
my Bool:D $f = False;
my Bool:D $r = False;
my Bool:D $w = False;
my Bool:D $x = False;

if $e
{
$d = $file.IO.d;
$f = $file.IO.f;
$r = $file.IO.r;
$w = $file.IO.w;
$x = $file.IO.x;
}

my PresenceHash:D $p = %(:$d, :$e, :$f, :$r, :$w, :$x);
}

Expand Down

0 comments on commit e6e6574

Please sign in to comment.