Class: Alx::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/alx/renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(conf) ⇒ Renderer

Returns a new instance of Renderer.



6
7
8
# File 'lib/alx/renderer.rb', line 6

def initialize( conf )
  @conf = conf
end

Instance Method Details

#render(book) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/alx/renderer.rb', line 14

def render( book )
  if @conf[ :html ]
    markdown = Redcarpet::Markdown.new( Redcarpet::Render::HTML.new, :fenced_code_blocks => true, :tables => true )
    return markdown.render( book.content )
  end
  book.content
end

#render_to_file(book, destination = nil) ⇒ Object



10
11
12
# File 'lib/alx/renderer.rb', line 10

def render_to_file( book, destination = nil )
  on_file( destination ) { | file | file.puts( render( book ) ) }
end