Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/blueprint-css/lib/blueprint/core_ext.rb

Class Method Summary collapse

Class Method Details

.path_to_string(path) ⇒ Object

string output from file



29
30
31
# File 'lib/blueprint-css/lib/blueprint/core_ext.rb', line 29

def self.path_to_string(path)
  File.new(path).read
end

.string_to_file(string, path) ⇒ Object

saves a string to a specified file path



34
35
36
37
38
# File 'lib/blueprint-css/lib/blueprint/core_ext.rb', line 34

def self.string_to_file(string, path)
  directory = File.dirname(path)
  FileUtils.mkdir_p directory unless File.directory?(directory)
  File.open(path, 'w') { |f| f << string }
end