Method: Pathname#read_lines

Defined in:
lib/pleasant_path/pathname.rb

#read_lines(eol: $/) ⇒ Array<String>

Note:

Not to be confused with Pathname#readlines, which retains end-of-line characters.

Reads all lines from the file indicated by the Pathname, and returns them with eol (end-of-line) characters stripped.

Examples:

File.read("path/to/file")                # == "one\ntwo\n"

Pathname.new("path/to/file").read_lines  # == ["one", "two"]

Parameters:

  • eol (String) (defaults to: $/)

Returns:

See Also:



1033
1034
1035
# File 'lib/pleasant_path/pathname.rb', line 1033

def read_lines(eol: $/)
  self.open("r"){|f| f.read_lines(eol: eol) }
end