Class: Tenderloin::VMXFile
- Inherits:
-
Object
- Object
- Tenderloin::VMXFile
- Defined in:
- lib/tenderloin/vmx_file.rb
Class Method Summary collapse
Class Method Details
.load(filename) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/tenderloin/vmx_file.rb', line 4 def self.load(filename) data = {} File.open(filename).each do |line| parts = line.split('=') data[parts[0].strip] = parts[1].strip.gsub!(/^"(.*?)"$/,'\1') end data end |
.with_vmx_data(filename, &block) ⇒ Object
21 22 23 24 25 |
# File 'lib/tenderloin/vmx_file.rb', line 21 def self.with_vmx_data(filename, &block) data = load(filename) block.call(data) write(filename, data) end |
.write(filename, data) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/tenderloin/vmx_file.rb', line 13 def self.write(filename, data) File.open(filename, 'w') do |f| data.each do |k,v| f.puts "#{k} = \"#{v}\"" end end end |