Sha256: 324a4bf93ed56fad0d3100e7f743db04005903049500d73c17705f88db363571

Contents?: true

Size: 880 Bytes

Versions: 10

Compression:

Stored size: 880 Bytes

Contents

# encoding: utf-8
# (c) 2011 Martin Kozák (martinkozak@martinkozak.net)

##
# File extension.
# @since 0.11.0
#

class File

    ##
    # Writes data to file and closes it in single call. Data are written
    # in binary mode since +0.11.1+.
    #
    # @param [String] filepath path to file
    # @param [String] data data for write
    # @return [Integer] length of really written data
    # @since 0.11.0
    #
    
    def self.write(filepath, data = "")
        len = nil
        File.open(filepath, "wb") do |io|
            len = io.write(data)
        end
        return len
    end
    
    ##
    # Creates file with zero size and closes it. (In fact, +touch+ is
    # usually used for it.)
    #
    # @param [String] file filepath path for create
    # @since 0.11.0
    #
    
    def self.touch(filepath)
        File.open(filepath, "wb").close()
    end
    
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hash-utils-0.18.1 lib/hash-utils/file.rb
hash-utils-0.18.0 lib/hash-utils/file.rb
hash-utils-0.17.1 lib/hash-utils/file.rb
hash-utils-0.17.0 lib/hash-utils/file.rb
hash-utils-0.16.0 lib/hash-utils/file.rb
hash-utils-0.15.0 lib/hash-utils/file.rb
hash-utils-0.14.0 lib/hash-utils/file.rb
hash-utils-0.13.1 lib/hash-utils/file.rb
hash-utils-0.12.0 lib/hash-utils/file.rb
hash-utils-0.11.1 lib/hash-utils/file.rb