Class: String
Instance Method Summary collapse
-
#/(child) ⇒ Pathname
Constructs a Pathname from the String, and appends
childto the Pathname. -
#^(sibling) ⇒ Pathname
deprecated
Deprecated.
Use Pathname#^.
-
#append_to_file(file) ⇒ self
Appends the String to the specified
file. -
#glob ⇒ Array<Pathname>
deprecated
Deprecated.
Use
Pathname.glob. -
#to_pathname ⇒ Pathname
(also: #path)
Constructs a Pathname from the String.
-
#write_to_file(file) ⇒ self
Writes the String to the specified
file, overwriting the file if it exists.
Instance Method Details
#/(child) ⇒ Pathname
Constructs a Pathname from the String, and appends child to the Pathname.
26 27 28 |
# File 'lib/pleasant_path/string.rb', line 26 def /(child) self.path / child end |
#^(sibling) ⇒ Pathname
Use Pathname#^.
Constructs a Pathname from the String, and appends sibling to the dirname of the Pathname.
The mnemonic for this operator is that the result is formed by going up one directory level from the original path, then going back down to sibling.
46 47 48 |
# File 'lib/pleasant_path/string.rb', line 46 def ^(sibling) self.path ^ sibling end |
#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.
96 97 98 99 |
# File 'lib/pleasant_path/string.rb', line 96 def append_to_file(file) file.to_pathname.append_text(self) self end |
#glob ⇒ Array<Pathname>
Use Pathname.glob.
Returns an array of Pathnames which match the filename pattern contained in the String.
61 62 63 |
# File 'lib/pleasant_path/string.rb', line 61 def glob Pathname.glob(self) end |
#to_pathname ⇒ Pathname Also known as: path
Constructs a Pathname from the String.
9 10 11 |
# File 'lib/pleasant_path/string.rb', line 9 def to_pathname Pathname.new(self) end |
#write_to_file(file) ⇒ self
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.
77 78 79 80 |
# File 'lib/pleasant_path/string.rb', line 77 def write_to_file(file) file.to_pathname.write_text(self) self end |