diff options
author | dakkar <dakkar@thenautilus.net> | 2015-09-10 15:46:11 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2015-09-10 15:46:11 +0100 |
commit | 99f8ccd6cddc6fa9a021d4118e6a706a19e474b1 (patch) | |
tree | 5316e1bbfed711087393f4a1e8fd103cbc5d9cfb /lib/WebCoso/File.pm | |
parent | work around rakudo bug #126006 (diff) | |
download | WebCoso-p6-99f8ccd6cddc6fa9a021d4118e6a706a19e474b1.tar.gz WebCoso-p6-99f8ccd6cddc6fa9a021d4118e6a706a19e474b1.tar.bz2 WebCoso-p6-99f8ccd6cddc6fa9a021d4118e6a706a19e474b1.zip |
maybe I got deps working
I'd still like to make the whole thing more readable, though
Diffstat (limited to 'lib/WebCoso/File.pm')
-rw-r--r-- | lib/WebCoso/File.pm | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/WebCoso/File.pm b/lib/WebCoso/File.pm new file mode 100644 index 0000000..764cf2f --- /dev/null +++ b/lib/WebCoso/File.pm @@ -0,0 +1,31 @@ +# -*- mode: perl6 -*- +class WebCoso::File { + has Str $.path; + has $.lang; + has $!contents; + + multi method new($self: $path) { + $self.bless(:$path); + } + + submethod BUILD(Str(Cool) :$!lang, Str(Cool) :$!path) {} + + multi method contents() { + return $!contents //= $.parse(); + } + multi method contents($new_contents) { + return $!contents = $.serialise($new_contents); + } + + method parse() { + return $.path.IO.slurp(); + } + method serialise($contents) { + $.path.IO.spurt($contents); + return $contents; + } + + method modified() { + return $.path.IO.modified; + } +} |