Sha256: 9ac3d0ad20536dba490af23a4a906dcd0ec00e27682456e3f028a6d002019ff2

Contents?: true

Size: 687 Bytes

Versions: 1

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true

module FunRuby
  # Module containing methods for files
  module File
    include Common::Helpers

    extend self

    # Writes a given content to a given file
    #
    # @since 0.1.0
    #
    # @param filepath [::String]
    # @param content [::String]
    #
    # @example Basics
    #   tmp = Tempfile.new("file.txt")
    #   F::File.write(tmp.path, "abc")
    #   File.read(tmp.path) #=> "abc"
    #   tmp.unlink
    def write(filepath = F._, content = F._)
      curry_implementation(:write, filepath, content)
    end

    private

    def _write(filepath, content)
      ::File.open(filepath, "w") { |file| file.write(content) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fun-ruby-0.0.1 lib/fun_ruby/file.rb