Sha256: 02a9db630cfcb7fb7940b35e3f418ae0e74e58d762663f12f2b8386316c97cc8

Contents?: true

Size: 633 Bytes

Versions: 2

Compression:

Stored size: 633 Bytes

Contents

module Kmkr
  class FileManager
    attr_reader :current_dir

    def initialize(prefix, extension, current_dir = Dir.pwd, suffix = "")
      @current_dir = current_dir
      @prefix = prefix
      @extension = extension
      @suffix = suffix
    end

    def create_file
      create_directory unless File.exist?(current_dir)
      File.new(filename, 'w').close unless File.exist?(filename)
    end

    private

    attr_reader :prefix, :extension, :suffix

    def filename
      filename = "#{current_dir}/#{prefix}#{suffix}.#{extension}"
    end

    def create_directory
      FileUtils.mkdir_p(current_dir)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kmkr-0.0.2 lib/kmkr/file_manager.rb
kmkr-0.0.1 lib/kmkr/file_manager.rb