Class: GhostWriter::IndexWriter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ghost_writer/index_writer/base.rb

Direct Known Subclasses

Markdown, Rack, Rst

Instance Method Summary collapse

Constructor Details

#initialize(document_index) ⇒ Base

Returns a new instance of Base.



3
4
5
# File 'lib/ghost_writer/index_writer/base.rb', line 3

def initialize(document_index)
  @document_index = document_index
end

Instance Method Details

#write_fileObject



7
8
9
10
11
12
13
14
15
# File 'lib/ghost_writer/index_writer/base.rb', line 7

def write_file
  unless File.exist?(File.dirname(@document_index.basename))
    FileUtils.mkdir_p(File.dirname(@document_index.basename))
  end

  File.open("#{@document_index.basename}.#{extname}", "w") do |f|
    f.write template.result(@document_index.instance_eval { binding })
  end
end