Class: Mdify::Renderer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject (readonly)

Returns the value of attribute content.



5
6
7
# File 'lib/mdify/renderer.rb', line 5

def content
  @content
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/mdify/renderer.rb', line 5

def title
  @title
end

Instance Method Details

#renderObject



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