Sha256: 91d2a69a3383e551c4c1d7afe09a2c76530b92b612e488026829e7fdcf86d306

Contents?: true

Size: 985 Bytes

Versions: 4

Compression:

Stored size: 985 Bytes

Contents

# frozen_string_literal: true

module AnnotateRb
  module ModelAnnotator
    module Annotation
      class MarkdownHeader < Components::Base
        MD_NAMES_OVERHEAD = 6
        MD_TYPE_ALLOWANCE = 18

        attr_reader :max_size

        def initialize(max_size)
          @max_size = max_size
        end

        def to_markdown
          name_padding = max_size + MD_NAMES_OVERHEAD
          # standard:disable Lint/FormatParameterMismatch
          formatted_headers = format("# %-#{name_padding}.#{name_padding}s | %-#{MD_TYPE_ALLOWANCE}.#{MD_TYPE_ALLOWANCE}s | %s",
            "Name",
            "Type",
            "Attributes")
          # standard:enable Lint/FormatParameterMismatch

          <<~HEADER.strip
            # ### Columns
            #
            #{formatted_headers}
            # #{"-" * name_padding} | #{"-" * MD_TYPE_ALLOWANCE} | #{"-" * 27}
          HEADER
        end

        def to_default
          nil
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
annotaterb-4.13.0 lib/annotate_rb/model_annotator/annotation/markdown_header.rb
annotaterb-4.12.0 lib/annotate_rb/model_annotator/annotation/markdown_header.rb
annotaterb-4.11.0 lib/annotate_rb/model_annotator/annotation/markdown_header.rb
annotaterb-4.10.2 lib/annotate_rb/model_annotator/annotation/markdown_header.rb