Sha256: d6d2347df8f9e8252c3cc28e0a5327751ee31e4c34386acbf2dae12ed988706c

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module AnnotateRb
  module ModelAnnotator
    # Shared annotation components
    module Components
      class Base
        # Methods default to #to_default, unless overridden by sub class
        def to_markdown
          to_default
        end

        def to_rdoc
          to_default
        end

        def to_yard
          to_default
        end

        def to_default
          raise NoMethodError, "Not implemented by class #{self.class}"
        end
      end

      class NilComponent < Base
        # Used when we want to return a component, but does not affect annotation generation.
        # It will get ignored when the consuming object calls Array#compact
        def to_default
          nil
        end
      end

      class LineBreak < Base
        def to_default
          ""
        end
      end

      class BlankCommentLine < Base
        def to_default
          "#"
        end
      end

      class Header < Base
        attr_reader :header

        def initialize(header)
          @header = header
        end

        def to_default
          "# #{header}"
        end

        def to_markdown
          "# ### #{header}"
        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/components.rb
annotaterb-4.12.0 lib/annotate_rb/model_annotator/components.rb
annotaterb-4.11.0 lib/annotate_rb/model_annotator/components.rb
annotaterb-4.10.2 lib/annotate_rb/model_annotator/components.rb