Class: AssetTrip::FileWriter

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

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileWriter

Returns a new instance of FileWriter.



4
5
6
# File 'lib/asset_trip/file_writer.rb', line 4

def initialize(path)
  @path = path
end

Instance Method Details

#write!(contents) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/asset_trip/file_writer.rb', line 8

def write!(contents)
  FileUtils.mkdir_p(File.dirname(@path))

  File.open(@path, "w") do |file|
    file << contents
  end
end