Sha256: f00b54981e65bea0411a8224745a7a4621f20957887cecd81a97e5948e2224db

Contents?: true

Size: 503 Bytes

Versions: 3

Compression:

Stored size: 503 Bytes

Contents

class File

  unless defined?(write)  # 1.9+

    # Writes the given data to the given path and closes the file.  This is
    # done in binary mode, complementing <tt>IO.read</tt> in standard Ruby.
    #
    #   str = 'The content for the file'
    #   File.write('tmp/write.txt', str)
    #
    # Returns the number of bytes written.
    #
    # CREDIT: Gavin Sinclair

    def self.write(path, data)
      File.open(path, "wb") do |file|
        return file.write(data)
      end
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.9.0 lib/core/facets/file/write.rb
facets-2.9.0.pre.2 lib/core/facets/file/write.rb
facets-2.9.0.pre.1 lib/core/facets/file/write.rb