Class: File
- Inherits:
-
Object
- Object
- File
- Defined in:
- lib/audio_addict/extensions/file.rb
Class Method Summary collapse
- .append(file, content) ⇒ Object
- .contains?(file, content) ⇒ Boolean
- .deep_write(file, content) ⇒ Object
Class Method Details
.append(file, content) ⇒ Object
12 13 14 |
# File 'lib/audio_addict/extensions/file.rb', line 12 def self.append(file, content) open(file, 'a') { |f| f.puts content } end |
.contains?(file, content) ⇒ Boolean
4 5 6 7 8 9 10 |
# File 'lib/audio_addict/extensions/file.rb', line 4 def self.contains?(file, content) return false unless File.exist? file foreach file do |line| return true if line.chomp == content end return false end |
.deep_write(file, content) ⇒ Object
16 17 18 19 20 |
# File 'lib/audio_addict/extensions/file.rb', line 16 def self.deep_write(file, content) dir = File.dirname file FileUtils.mkdir_p dir unless Dir.exist? dir File.write file, content end |