Class: FileSystem
- Inherits:
-
Object
- Object
- FileSystem
- Defined in:
- lib/brisk/file_system.rb
Class Method Summary collapse
- .append(file, value) ⇒ Object
- .copy_file(from, to) ⇒ Object
- .create_dir(directory) ⇒ Object
- .create_file(file, permissions = 'w') ⇒ Object
- .delete(file) ⇒ Object
- .dir_exists?(directory) ⇒ Boolean
- .file_exists?(file) ⇒ Boolean
- .get_path(file, path) ⇒ Object
- .read(path) ⇒ Object
- .write(file, value) ⇒ Object
Class Method Details
.append(file, value) ⇒ Object
39 40 41 |
# File 'lib/brisk/file_system.rb', line 39 def self.append(file, value) File.open(file, 'a') { |f| f.puts value} end |
.copy_file(from, to) ⇒ Object
13 14 15 |
# File 'lib/brisk/file_system.rb', line 13 def self.copy_file(from, to) FileUtils.copy(from, to) end |
.create_dir(directory) ⇒ Object
3 4 5 6 7 |
# File 'lib/brisk/file_system.rb', line 3 def self.create_dir(directory) unless dir_exists?(directory) FileUtils.mkdir_p(directory, :mode => 0755) end end |
.create_file(file, permissions = 'w') ⇒ Object
9 10 11 |
# File 'lib/brisk/file_system.rb', line 9 def self.create_file(file, = 'w') File.new(file, ) end |
.delete(file) ⇒ Object
43 44 45 |
# File 'lib/brisk/file_system.rb', line 43 def self.delete(file) File.delete(file) end |
.dir_exists?(directory) ⇒ Boolean
21 22 23 |
# File 'lib/brisk/file_system.rb', line 21 def self.dir_exists?(directory) File.directory?(directory) end |
.file_exists?(file) ⇒ Boolean
25 26 27 |
# File 'lib/brisk/file_system.rb', line 25 def self.file_exists?(file) File.file?(file) end |
.get_path(file, path) ⇒ Object
17 18 19 |
# File 'lib/brisk/file_system.rb', line 17 def self.get_path(file, path) File.(file, path) end |
.read(path) ⇒ Object
29 30 31 |
# File 'lib/brisk/file_system.rb', line 29 def self.read(path) File.read(path) end |
.write(file, value) ⇒ Object
33 34 35 36 37 |
# File 'lib/brisk/file_system.rb', line 33 def self.write(file, value) File.open(file, "w+") do |f| f.write(value) end end |