Class: AnnotateRb::ModelAnnotator::CheckConstraintAnnotation::CheckConstraintComponent

Inherits:
AnnotateRb::ModelAnnotator::Components::Base show all
Defined in:
lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AnnotateRb::ModelAnnotator::Components::Base

#to_rdoc, #to_yard

Constructor Details

#initialize(name, expression, max_size) ⇒ CheckConstraintComponent

Returns a new instance of CheckConstraintComponent.



9
10
11
12
13
# File 'lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb', line 9

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

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



7
8
9
# File 'lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb', line 7

def expression
  @expression
end

#max_sizeObject (readonly)

Returns the value of attribute max_size.



7
8
9
# File 'lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb', line 7

def max_size
  @max_size
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb', line 7

def name
  @name
end

Instance Method Details

#to_defaultObject



15
16
17
18
19
# File 'lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb', line 15

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

#to_markdownObject



21
22
23
24
25
26
27
# File 'lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb', line 21

def to_markdown
  if expression
    sprintf("# * `%s`: `%s`", name, expression)
  else
    sprintf("# * `%s`", name)
  end
end