Sha256: 6a62ca052340e9eb5c81c3553fbedab9423811547052bc68193a875595a0d772
Contents?: true
Size: 1.06 KB
Versions: 7
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module Tocer module Elements # Represents a table of contents start and finish comment block. class CommentBlock def self.index lines, id (lines.index { |line| line =~ /<!--.*#{Regexp.escape id}.*-->/ }).to_i end def initialize start_id: "Tocer[start]", finish_id: "Tocer[finish]", message: "Auto-generated, don't remove." @start_id = start_id @finish_id = finish_id @message = message end def start_index lines self.class.index lines, start_id end def start_tag comment start_id, message end def finish_index lines self.class.index lines, finish_id end def finish_tag comment finish_id, message end def prependable? lines start_index(lines).zero? && finish_index(lines).zero? end private attr_reader :start_id, :finish_id, :message def comment id, message "<!-- #{id}: #{message} -->" end end end end
Version data entries
7 entries across 7 versions & 1 rubygems