Skip to content

Commit

Permalink
rewrite Dir::pwd(), add Dir::new(), add examples of Dir.pm
Browse files Browse the repository at this point in the history
  • Loading branch information
shelling committed Aug 18, 2009
1 parent a275554 commit 589a206
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions examples/dir.pl
@@ -0,0 +1,6 @@
#!/usr/bin/evn perl
#
use lib qw(lib examples/lib);
use Rubyish;

print Rubyish::Dir->pwd, "\n";
12 changes: 11 additions & 1 deletion lib/Rubyish/Dir.pm
Expand Up @@ -11,10 +11,20 @@ use 5.010;
use base "Rubyish::Object";
use Rubyish::Syntax::def;

sub new {
my ($class, $dirname) = @_;
return \$dirname, $class;
}

def pwd {

sub pwd {
my ($class) = @_;
if ($class eq __PACKAGE__) {
use Cwd;
cwd();
} elsif (ref($class)) {
warn "undefine method \'pwd\' for __PACKAGE__ instance";
}
};

1;
4 changes: 2 additions & 2 deletions t/dir.t
Expand Up @@ -3,9 +3,9 @@ use strict;

use Rubyish;

use Test::More;
use Test::More "no_plan";

plan tests => 1;
can_ok( "Rubyish::Dir", qw(new pwd) );

ok( Rubyish::Dir->pwd );

0 comments on commit 589a206

Please sign in to comment.