Class: FileManager

Inherits:
Object
  • Object
show all
Defined in:
lib/fundamentus_data/util/file_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(dir_path, options = {}) ⇒ FileManager

Returns a new instance of FileManager.



5
6
7
8
9
10
# File 'lib/fundamentus_data/util/file_manager.rb', line 5

def initialize(dir_path, options = {})
  @dir_path = dir_path
  if options.has_key?(:verbose)
    @verbose = options[:verbose]
  end
end

Instance Method Details

#save(file_name, content) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/fundamentus_data/util/file_manager.rb', line 12

def save(file_name, content)
  if @verbose
    puts "Saving content of length #{content.size} to #{@dir_path + file_name}"
  end
  File.open(@dir_path + file_name, 'w') do |f|
    f.write(content)
  end
end