Sha256: e338b6ea127053fa06c87b16645a46f7215ed70b842d9aa83e2630829c3d78ae

Contents?: true

Size: 1012 Bytes

Versions: 4

Compression:

Stored size: 1012 Bytes

Contents

# frozen_string_literal: true

module AnnotateRb
  module ModelAnnotator
    module ForeignKeyAnnotation
      class ForeignKeyComponent < Components::Base
        attr_reader :formatted_name, :constraints_info, :ref_info, :max_size

        def initialize(formatted_name, constraints_info, ref_info, max_size)
          @formatted_name = formatted_name
          @constraints_info = constraints_info
          @ref_info = ref_info
          @max_size = max_size
        end

        def to_markdown
          format("# * `%s`%s:\n#     * **`%s`**",
            formatted_name,
            constraints_info.blank? ? "" : " (_#{constraints_info}_)",
            ref_info)
        end

        def to_default
          # standard:disable Lint/FormatParameterMismatch
          format("#  %-#{max_size}.#{max_size}s %s %s",
            formatted_name,
            "(#{ref_info})",
            constraints_info).rstrip
          # standard:enable Lint/FormatParameterMismatch
        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/foreign_key_annotation/foreign_key_component.rb
annotaterb-4.12.0 lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb
annotaterb-4.11.0 lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb
annotaterb-4.10.2 lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb