Sha256: bac85a7336579faffcaa53f193539f0a092a375de2f36d8a6db04aafa33d4583

Contents?: true

Size: 439 Bytes

Versions: 17

Compression:

Stored size: 439 Bytes

Contents

class File

  # Creates a new file, or overwrites an existing file,
  # and writes a string into it. Can also take a block
  # just like File#open, which is yielded _after_ the
  # string is writ.
  #
  #   str = 'The content for the file'
  #   File.create('myfile.txt', str)
  #
  # CREDIT: George Moschovitis

  def self.create(path, str='', &blk)
    open(path, 'wb') do |f|
      f << str
      blk.call(f) if blk
    end
  end

end

Version data entries

17 entries across 16 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/file/create.rb
facets-3.1.0 lib/core/facets/file/create.rb
facets-3.0.0 lib/core/facets/file/create.rb
facets-2.9.3 lib/core/facets/file/create.rb
facets-2.9.2 src/core/facets/file/create.rb
facets-2.9.2 lib/core/facets/file/create.rb
facets-2.9.1 lib/core/facets/file/create.rb
facets-2.8.4 lib/core/facets/file/create.rb
facets-2.8.3 lib/core/facets/file/create.rb
facets-2.8.2 lib/core/facets/file/create.rb
facets-2.8.1 lib/core/facets/file/create.rb
facets-2.8.0 lib/core/facets/file/create.rb
facets-2.7.0 lib/core/facets/file/create.rb
facets-2.6.0 lib/core/facets/file/create.rb
facets-2.5.1 lib/core/facets/file/create.rb
facets-2.5.0 lib/core/facets/file/create.rb
facets-2.5.2 lib/core/facets/file/create.rb