Method: Pathname#append_file

Defined in:
lib/pleasant_path/pathname.rb

#append_file(source) ⇒ self

Appends the contents of file indicated by source to the file indicated by the Pathname. Returns the Pathname.

Examples:

File.read("yearly.log")  # == "one\ntwo\n"
File.read("daily.log")   # == "three\nfour\n"

Pathname.new("yearly.log").append_file("daily.log")
  # == Pathname.new("yearly.log")

File.read("yearly.log")  # == "one\ntwo\nthree\nfour\n"

Parameters:

Returns:

  • (self)


1105
1106
1107
1108
# File 'lib/pleasant_path/pathname.rb', line 1105

def append_file(source)
  self.open("a"){|destination| IO::copy_stream(source, destination) }
  self
end