Class: RgGen::OutputBase::FileWriter

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

Instance Method Summary collapse

Constructor Details

#initialize(pattern, body) ⇒ FileWriter

Returns a new instance of FileWriter.



4
5
6
7
# File 'lib/rggen/output_base/file_writer.rb', line 4

def initialize(pattern, body)
  @pattern  = Erubi::Engine.new(pattern)
  @body     = body
end

Instance Method Details

#write_file(context, output_directory = nil) ⇒ Object



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

def write_file(context, output_directory = nil)
  path  = generate_path(context, output_directory)
  code  = generate_code(context, path)
  create_output_directory(path)
  File.binwrite(path, code)
end