Sha256: 0fbadaacb52c736081ec0997c0405b5d5db883cada91052b4a0537e4fb3d39de
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
class String # Constructs a Pathname from the String. # # @example # "path/to/file".to_pathname # == Pathname.new("path/to/file") # # @return [Pathname] def to_pathname Pathname.new(self) end # Alias of {String#to_pathname}. # # @return [Pathname] alias :path :to_pathname # Constructs a Pathname from the String, and appends +child+ to the # Pathname. # # @example # "path/to" / "file" # == Pathname.new("path/to/file") # # @param child [String] # @return [Pathname] def /(child) self.path / child end # Writes the String to the specified +file+, overwriting the file if # it exists. Creates the file if it does not exist, including # any necessary parent directories. Returns the String. # # @see Pathname#write_text # # @example # "hello world".write_to_file("out.txt") # == "hello world" # File.read("out.txt") # == "hello world" # # @param file [String, Pathname] # @return [self] def write_to_file(file) file.to_pathname.write_text(self) self end # Appends the String to the specified +file+. Creates the file if it # does not exist, including any necessary parent directories. Returns # the String. # # @see Pathname#append_text # # @example # "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" # # @param file [String, Pathname] # @return [self] def append_to_file(file) file.to_pathname.append_text(self) self end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pleasant_path-2.0.0 | lib/pleasant_path/string.rb |