Created
January 26, 2012 13:03
-
-
Save anonymous/1682667 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
class Db { | |
has Str $.name is rw; | |
has Int $.lvl is rw = 0; | |
has @!tb is rw; | |
has $!path = %*ENV<HOME>~'/.db'; | |
method op( Str $dbname ){ | |
if $dbname ~~ any( dir $!path ) { | |
@!tb = dir $!path~'/'~$dbname; | |
say "Database $dbname opened."; | |
warn "Database is empty...\n" if dir $!path~'/'~$dbname; | |
return self.new( :name($dbname), :lvl(0) ); | |
} else { | |
say "Warning: there is not database named $dbname\nYou should use .create\n"; | |
return 0; | |
} | |
} | |
} | |
my $obj = Db.op('test'); | |
say $obj.name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment