Method: IO#read_lines

Defined in:
lib/pleasant_path/io.rb

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

Note:

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

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

Examples:

File.read("in.txt")          # == "one\ntwo\n"

File.open("in.txt") do |io|
  io.read_lines              # == ["one", "two"]
end                          # == ["one", "two"]

Parameters:

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

Returns:



42
43
44
# File 'lib/pleasant_path/io.rb', line 42

def read_lines(eol: $/)
  self.readlines(eol, chomp: true)
end