Module: AsFoo::AsMarkdown

Included in:
String
Defined in:
lib/as_foo/as_markdown.rb

Instance Method Summary collapse

Instance Method Details

#as_markdown(with: :redcarpet, options: nil) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/as_foo/as_markdown.rb', line 3

def as_markdown(with: :redcarpet, options: nil)
  case with
  when :redcarpet
    require 'redcarpet'
    Redcarpet::Markdown.new(Redcarpet::Render::HTML, options.to_h).render(self.to_s)
  else
    raise ArgumentError.new("unexpected method #{with}")
  end
end