lib/folio/document.rb in folio-0.1.0 vs lib/folio/document.rb in folio-0.2.0
- old
+ new
@@ -12,11 +12,12 @@
#--
# Polymorphism
#++
- def file? ; true ; end
+ #def file? ; true ; end
+ def document? ; true ; end
#--
# FileTest::
#++
@@ -44,9 +45,21 @@
end
def truncate(size)
::File.open(path, 'w'){|f| f.truncate(size)}
end
+
+ # Replace contents of file with string.
+ def write(string)
+ ::File.open(path, 'w'){|f| f.write(string)}
+ end
+ alias_method :<, :write # NOTE: Sure about this? It means no Comparable.
+
+ # Replace contents of file with string.
+ def append(string)
+ ::File.open(path, 'a'){|f| f.write(string)}
+ end
+ alias_method :<<, :append
#--
# Can we handle other modes besides read this way?
#++