Class: Alx::Renderer
- Inherits:
-
Object
- Object
- Alx::Renderer
- Defined in:
- lib/alx/renderer.rb
Instance Method Summary collapse
-
#initialize(conf) ⇒ Renderer
constructor
A new instance of Renderer.
- #render(book) ⇒ Object
- #render_to_file(book, destination = nil) ⇒ Object
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 |