Class: Inkmark::Toc
- Inherits:
-
Object
- Object
- Inkmark::Toc
- Defined in:
- lib/inkmark/toc.rb
Overview
A rendered table of contents, carrying both Markdown and HTML renderings. Returned by #toc when the toc: true, statistics: true, or extract: { headings: true } option is set; nil otherwise.
Immutable value object: the instance is frozen at construction, and == / eql? / hash implement value-equality over the two fields.
Instance Attribute Summary collapse
-
#html ⇒ Object
(also: #to_html)
readonly
Returns the value of attribute html.
-
#markdown ⇒ Object
(also: #to_markdown)
readonly
Returns the value of attribute markdown.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(markdown:, html:) ⇒ Toc
constructor
A new instance of Toc.
- #to_s ⇒ Object
Constructor Details
#initialize(markdown:, html:) ⇒ Toc
Returns a new instance of Toc.
23 24 25 26 27 |
# File 'lib/inkmark/toc.rb', line 23 def initialize(markdown:, html:) @markdown = markdown @html = html freeze end |
Instance Attribute Details
#html ⇒ Object (readonly) Also known as: to_html
Returns the value of attribute html.
19 20 21 |
# File 'lib/inkmark/toc.rb', line 19 def html @html end |
#markdown ⇒ Object (readonly) Also known as: to_markdown
Returns the value of attribute markdown.
19 20 21 |
# File 'lib/inkmark/toc.rb', line 19 def markdown @markdown end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
31 32 33 |
# File 'lib/inkmark/toc.rb', line 31 def ==(other) other.is_a?(Toc) && other.markdown == @markdown && other.html == @html end |
#hash ⇒ Object
36 37 38 |
# File 'lib/inkmark/toc.rb', line 36 def hash [self.class, @markdown, @html].hash end |
#to_s ⇒ Object
29 |
# File 'lib/inkmark/toc.rb', line 29 def to_s = @markdown |