Class: MarkdownRubyDocumentation::MarkdownPresenter
- Inherits:
-
Object
- Object
- MarkdownRubyDocumentation::MarkdownPresenter
- Defined in:
- lib/markdown_ruby_documentation/markdown_presenter.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#title_key ⇒ Object
readonly
Returns the value of attribute title_key.
Instance Method Summary collapse
- #call(items = nil) ⇒ Object
-
#initialize(items: nil, summary:, title_key:, skip_blanks: true) ⇒ MarkdownPresenter
constructor
A new instance of MarkdownPresenter.
Constructor Details
#initialize(items: nil, summary:, title_key:, skip_blanks: true) ⇒ MarkdownPresenter
Returns a new instance of MarkdownPresenter.
6 7 8 9 10 11 12 |
# File 'lib/markdown_ruby_documentation/markdown_presenter.rb', line 6 def initialize(items: nil, summary:, title_key:, skip_blanks: true) @items = items @summary = summary @title_key = title_key @skip_blanks = skip_blanks @present_items = [] end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
4 5 6 |
# File 'lib/markdown_ruby_documentation/markdown_presenter.rb', line 4 def items @items end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
4 5 6 |
# File 'lib/markdown_ruby_documentation/markdown_presenter.rb', line 4 def summary @summary end |
#title_key ⇒ Object (readonly)
Returns the value of attribute title_key.
4 5 6 |
# File 'lib/markdown_ruby_documentation/markdown_presenter.rb', line 4 def title_key @title_key end |
Instance Method Details
#call(items = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/markdown_ruby_documentation/markdown_presenter.rb', line 14 def call(items=nil) @items ||= items return "" if nothing_to_display? md = ["# #{summary.title}", "#{summary.summary}\n".gsub(/\n\n\n/, "\n\n"), class_level_comment, instances_methods, class_methods, "#{null_methods}\n".gsub(/\n\n\n/, "\n\n")] .reject(&:empty?) .join("\n") .gsub(/[\n]{3,}/, "\n\n") .gsub(/[\n]+\Z/, "\n\n") other_types! md end |