Class: MongoidMarkdownExtension::Markdown
- Inherits:
-
String
- Object
- String
- MongoidMarkdownExtension::Markdown
- Defined in:
- lib/mongoid_markdown_extension/markdown.rb
Class Attribute Summary collapse
Class Method Summary collapse
- .configure {|configuration| ... } ⇒ Object
- .demongoize(value) ⇒ Object
- .evolve(value) ⇒ Object
- .mongoize(value) ⇒ Object
- .reset ⇒ Object
Instance Method Summary collapse
-
#initialize(str) ⇒ Markdown
constructor
A new instance of Markdown.
- #to_html ⇒ Object
- #to_inline_html(line_breaks: false) ⇒ Object
- #to_stripped_s ⇒ Object
Constructor Details
#initialize(str) ⇒ Markdown
Returns a new instance of Markdown.
40 41 42 |
# File 'lib/mongoid_markdown_extension/markdown.rb', line 40 def initialize(str) super(str.to_s) end |
Class Attribute Details
.configuration ⇒ Object
10 11 12 |
# File 'lib/mongoid_markdown_extension/markdown.rb', line 10 def self.configuration @configuration ||= Configuration.new end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
18 19 20 |
# File 'lib/mongoid_markdown_extension/markdown.rb', line 18 def self.configure yield(configuration) end |
.demongoize(value) ⇒ Object
22 23 24 |
# File 'lib/mongoid_markdown_extension/markdown.rb', line 22 def self.demongoize(value) Markdown.new(value) end |
.evolve(value) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/mongoid_markdown_extension/markdown.rb', line 33 def self.evolve(value) case value when Markdown then value.mongoize else value end end |
.mongoize(value) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/mongoid_markdown_extension/markdown.rb', line 26 def self.mongoize(value) case value when Markdown then value.mongoize else value end end |
.reset ⇒ Object
14 15 16 |
# File 'lib/mongoid_markdown_extension/markdown.rb', line 14 def self.reset @configuration = Configuration.new end |
Instance Method Details
#to_html ⇒ Object
44 45 46 |
# File 'lib/mongoid_markdown_extension/markdown.rb', line 44 def to_html markdown_renderer.render(to_s).html_safe end |
#to_inline_html(line_breaks: false) ⇒ Object
48 49 50 51 52 |
# File 'lib/mongoid_markdown_extension/markdown.rb', line 48 def to_inline_html(line_breaks: false) rendered = markdown_inline_renderer.render(to_s).gsub(/(<br\s?\/?>)+?\z/, '') rendered.gsub!(/(<br\s?\/?>)+?\Z/, '') if !line_breaks rendered.html_safe end |
#to_stripped_s ⇒ Object
54 55 56 |
# File 'lib/mongoid_markdown_extension/markdown.rb', line 54 def to_stripped_s markdown_stripdown_renderer.render(to_s).try(:strip) end |