Method: String#append_to_file

Defined in:
lib/pleasant_path/string.rb

#append_to_file(file) ⇒ self

Appends the String to the specified file. Creates the file if it does not exist, including any necessary parent directories. Returns the String.

Examples:

"hello".append_to_file("out.txt")   # == "hello"
File.read("out.txt")                # == "hello"
" world".append_to_file("out.txt")  # == " world"
File.read("out.txt")                # == "hello world"

Parameters:

Returns:

  • (self)

See Also:



61
62
63
64
# File 'lib/pleasant_path/string.rb', line 61

def append_to_file(file)
  file.to_pathname.append_text(self)
  self
end