Class: Tocer::Elements::CommentBlock
- Inherits:
-
Object
- Object
- Tocer::Elements::CommentBlock
- Defined in:
- lib/tocer/elements/comment_block.rb
Overview
Represents a table of contents start and finish comment block.
Class Method Summary collapse
Instance Method Summary collapse
- #finish_index(lines) ⇒ Object
- #finish_tag ⇒ Object
-
#initialize(start_id: "Tocer[start]", finish_id: "Tocer[finish]", message: "Auto-generated, don't remove.") ⇒ CommentBlock
constructor
A new instance of CommentBlock.
- #prependable?(lines) ⇒ Boolean
- #start_index(lines) ⇒ Object
- #start_tag ⇒ Object
Constructor Details
#initialize(start_id: "Tocer[start]", finish_id: "Tocer[finish]", message: "Auto-generated, don't remove.") ⇒ CommentBlock
Returns a new instance of CommentBlock.
11 12 13 14 15 16 17 18 |
# File 'lib/tocer/elements/comment_block.rb', line 11 def initialize start_id: "Tocer[start]", finish_id: "Tocer[finish]", message: "Auto-generated, don't remove." @start_id = start_id @finish_id = finish_id = end |
Class Method Details
.index(lines, id) ⇒ Object
7 8 9 |
# File 'lib/tocer/elements/comment_block.rb', line 7 def self.index lines, id (lines.index { |line| line =~ /\<\!\-\-.*#{Regexp.escape id}.*\-\-\>/ }).to_i end |
Instance Method Details
#finish_index(lines) ⇒ Object
28 29 30 |
# File 'lib/tocer/elements/comment_block.rb', line 28 def finish_index lines self.class.index lines, finish_id end |
#finish_tag ⇒ Object
32 33 34 |
# File 'lib/tocer/elements/comment_block.rb', line 32 def finish_tag comment finish_id, end |
#prependable?(lines) ⇒ Boolean
36 37 38 |
# File 'lib/tocer/elements/comment_block.rb', line 36 def prependable? lines start_index(lines).zero? && finish_index(lines).zero? end |
#start_index(lines) ⇒ Object
20 21 22 |
# File 'lib/tocer/elements/comment_block.rb', line 20 def start_index lines self.class.index lines, start_id end |
#start_tag ⇒ Object
24 25 26 |
# File 'lib/tocer/elements/comment_block.rb', line 24 def start_tag comment start_id, end |