Class: ReVIEW::Converter

Inherits:
Object show all
Defined in:
lib/review/converter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(book, builder) ⇒ Converter

Returns a new instance of Converter.



10
11
12
13
14
# File 'lib/review/converter.rb', line 10

def initialize(book, builder)
  @book = book
  @book.config['builder'] = builder.target_name
  @compiler = ReVIEW::Compiler.new(builder)
end

Instance Attribute Details

#targetObject

Returns the value of attribute target.



8
9
10
# File 'lib/review/converter.rb', line 8

def target
  @target
end

Instance Method Details

#convert(file, output_path) ⇒ Object



16
17
18
19
20
21
# File 'lib/review/converter.rb', line 16

def convert(file, output_path)
  chap_name = File.basename(file, '.*')
  chap = @book.chapter(chap_name)
  result = @compiler.compile(chap)
  File.open(output_path, 'w') { |f| f.puts result }
end