Sha256: dd3b321d21b278a9c6f01f3375a8d0607f477fabff0247d6a6cd6f14ae3f6a0b

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

module ArticleFixtureGen
  module Data
    # Encapsulates a "single marker-tag pair", or sMTP; an HTML anchor tag with
    # a specifically-formatted ID attribute, an empty :href attribute, and no
    # enclosed content. Different than a "paired marker-tag pair", which is
    # analogous to two slightly differently-formatted sMTPs separated by content
    # (and with no overlapping pMTPs).
    class SingleMarkerTagPair
      def initialize(config:, counter:)
        @counter = counter
        @label = config.smtp_text
        IceNine.deep_freeze self
      end

      def to_html
        ['<a href="" id="', '"></a>'].join html_id
      end
      alias_method :to_s, :to_html

      private

      attr_reader :counter, :label

      def html_id
        [label, counter.to_s].join '-'
      end
    end # class ArticleFixtureGen::Data::SingleMarkerTagPair
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
article_fixture_gen-0.1.2 lib/article_fixture_gen/data/single_marker_tag_pair.rb
article_fixture_gen-0.1.1 lib/article_fixture_gen/data/single_marker_tag_pair.rb