Class: RgGen::Core::OutputBase::FileWriter
- Defined in:
- lib/rggen/core/output_base/file_writer.rb
Instance Method Summary collapse
-
#initialize(pattern, &body) ⇒ FileWriter
constructor
A new instance of FileWriter.
- #write_file(context, directory = nil) ⇒ Object
Constructor Details
#initialize(pattern, &body) ⇒ FileWriter
Returns a new instance of FileWriter.
7 8 9 10 |
# File 'lib/rggen/core/output_base/file_writer.rb', line 7 def initialize(pattern, &body) @pattern = Erubi::Engine.new(pattern) @body = body end |
Instance Method Details
#write_file(context, directory = nil) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rggen/core/output_base/file_writer.rb', line 12 def write_file(context, directory = nil) path = generate_path(context, directory) content = generate_content(context, path) create_directory(path) File.binwrite(path, content) end |