Sha256: 645c39661bcec3c311c57253667222fddaa7b37be92ed1d644cd2693c798aa60

Contents?: true

Size: 811 Bytes

Versions: 4

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

module AnnotateRb
  module ModelAnnotator
    module CheckConstraintAnnotation
      class CheckConstraintComponent < Components::Base
        attr_reader :name, :expression, :max_size

        def initialize(name, expression, max_size)
          @name = name
          @expression = expression
          @max_size = max_size
        end

        def to_default
          # standard:disable Lint/FormatParameterMismatch
          sprintf("#  %-#{max_size}.#{max_size}s %s", name, expression).rstrip
          # standard:enable Lint/FormatParameterMismatch
        end

        def to_markdown
          if expression
            sprintf("# * `%s`: `%s`", name, expression)
          else
            sprintf("# * `%s`", name)
          end
        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/check_constraint_annotation/check_constraint_component.rb
annotaterb-4.12.0 lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb
annotaterb-4.11.0 lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb
annotaterb-4.10.2 lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb