Class: Dropdown::MarkdownRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/dropdown/markdown_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ MarkdownRenderer

Returns a new instance of MarkdownRenderer.



8
9
10
11
# File 'lib/dropdown/markdown_renderer.rb', line 8

def initialize(file_path)
  @file_path = file_path
  @markdown = Redcarpet::Markdown.new Redcarpet::Render::HTML
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



5
6
7
# File 'lib/dropdown/markdown_renderer.rb', line 5

def file_path
  @file_path
end

#readerObject

Returns the value of attribute reader.



6
7
8
# File 'lib/dropdown/markdown_renderer.rb', line 6

def reader
  @reader
end

Instance Method Details

#output_filenameObject



17
18
19
# File 'lib/dropdown/markdown_renderer.rb', line 17

def output_filename
  File.basename(file_path, '.md') + '.html'
end

#renderObject



13
14
15
# File 'lib/dropdown/markdown_renderer.rb', line 13

def render
  @markdown.render reader.read(file_path)
end