Class: Mdify::Renderer
- Inherits:
-
Object
- Object
- Mdify::Renderer
- Defined in:
- lib/mdify/renderer.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(filename) ⇒ Renderer
constructor
A new instance of Renderer.
- #render ⇒ Object
Constructor Details
#initialize(filename) ⇒ Renderer
Returns a new instance of Renderer.
7 8 9 10 |
# File 'lib/mdify/renderer.rb', line 7 def initialize(filename) @title = filename.split("/").last @content = File.read(filename) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
5 6 7 |
# File 'lib/mdify/renderer.rb', line 5 def content @content end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/mdify/renderer.rb', line 5 def title @title end |
Instance Method Details
#render ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mdify/renderer.rb', line 12 def render html = Redcarpet.new(@content).to_html document = render_html(@title, html) temp_file = create_temp_file(document) if RUBY_PLATFORM.downcase.include?("darwin") exec "open #{temp_file}" else exec "launchy #{temp_file}" end end |