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.



12
13
14
15
16
# File 'lib/review/converter.rb', line 12

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.



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

def target
  @target
end

Instance Method Details

#convert(file, output_path) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/review/converter.rb', line 18

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