Sha256: c7b8f53e7cf04e137cd4b7930115ab1f32a065abbcb7d3cefc9b0ed352f24bfe
Contents?: true
Size: 1.07 KB
Versions: 22
Compression:
Stored size: 1.07 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
22 entries across 22 versions & 1 rubygems