Class: MarkupAttr::Markup
- Inherits:
-
Object
- Object
- MarkupAttr::Markup
- Defined in:
- lib/markup_attr/markup.rb
Class Attribute Summary collapse
-
.markdown_processor ⇒ Object
Returns the value of attribute markdown_processor.
Instance Attribute Summary collapse
-
#markup ⇒ Object
Returns the value of attribute markup.
Instance Method Summary collapse
- #default_markdown_processor ⇒ Object
-
#initialize(format, text) ⇒ Markup
constructor
A new instance of Markup.
- #to_html ⇒ Object
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_processor ⇒ Object
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
#markup ⇒ Object
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_processor ⇒ Object
20 21 22 |
# File 'lib/markup_attr/markup.rb', line 20 def default_markdown_processor Redcarpet end |
#to_html ⇒ Object
24 25 26 |
# File 'lib/markup_attr/markup.rb', line 24 def to_html @markup.to_html end |