Sha256: 419971b7b378c64ea817e74a30d010f89c58b6e75b8dd10b870af1cfcb5e9493

Contents?: true

Size: 774 Bytes

Versions: 1

Compression:

Stored size: 774 Bytes

Contents

class IO

  # Writes each string plus a succeeding new line character
  # (<code>$/</code>) to the IO.  Returns the lines unmodified.
  #
  # @param lines [Array<String>]
  # @return [Array<String>]
  def write_lines(lines)
    lines.each do |line|
      self.write(line)
      self.write($/)
    end
    self.write('') # write something even if no lines
    lines
  end

  # Reads from the IO all lines, and returns them as an array,
  # end-of-line characters excluded.  The <code>$/</code> global string
  # specifies what end-of-line characters to look for.
  #
  # (Not to be confused with +IO#readlines+ which retains end-of-line
  # characters in every string it returns.)
  #
  # @return [Array<String>]
  def read_lines
    self.readlines.each(&:chomp!)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pleasant_path-1.0.0 lib/pleasant_path/io.rb