Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/co2.rb

Class Method Summary collapse

Class Method Details

.prepend(path, string) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/co2.rb', line 7

def self.prepend(path, string)
  Tempfile.open File.basename(path) do |tempfile|
    tempfile << string

    File.open(path, 'r+') do |file|
      tempfile << file.read
      file.pos = tempfile.pos = 0
      file << tempfile.read
    end
  end
end