Class: MarkupAttr::Markup

Inherits:
Object
  • Object
show all
Defined in:
lib/markup_attr/markup.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format, text) ⇒ Markup

Returns a new instance of Markup.



9
10
11
12
13
14
15
16
17
18
# File 'lib/markup_attr/markup.rb', line 9

def initialize(format, text)
  case format
  when :markdown
    @markup = (self.class.markdown_processor || default_markdown_processor).new(text)
  when :textile
    @markup = RedCloth.new(text)
  else
    raise ArgumentError, "expected format to be :textile or :markdown; received #{format.inspect}"
  end
end

Class Attribute Details

.markdown_processorObject

Returns the value of attribute markdown_processor.



6
7
8
# File 'lib/markup_attr/markup.rb', line 6

def markdown_processor
  @markdown_processor
end

Instance Attribute Details

#markupObject

Returns the value of attribute markup.



3
4
5
# File 'lib/markup_attr/markup.rb', line 3

def markup
  @markup
end

Instance Method Details

#default_markdown_processorObject



20
21
22
# File 'lib/markup_attr/markup.rb', line 20

def default_markdown_processor
  Redcarpet
end

#to_htmlObject



24
25
26
# File 'lib/markup_attr/markup.rb', line 24

def to_html
  @markup.to_html
end