diff options
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; + } +} |