Class: AnnotateRb::ModelAnnotator::CheckConstraintAnnotation::CheckConstraintComponent
- Inherits:
-
AnnotateRb::ModelAnnotator::Components::Base
- Object
- AnnotateRb::ModelAnnotator::Components::Base
- AnnotateRb::ModelAnnotator::CheckConstraintAnnotation::CheckConstraintComponent
- Defined in:
- lib/annotate_rb/model_annotator/check_constraint_annotation/check_constraint_component.rb
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#max_size ⇒ Object
readonly
Returns the value of attribute max_size.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, expression, max_size) ⇒ CheckConstraintComponent
constructor
A new instance of CheckConstraintComponent.
- #to_default ⇒ Object
- #to_markdown ⇒ Object
Methods inherited from AnnotateRb::ModelAnnotator::Components::Base
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
#expression ⇒ Object (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_size ⇒ Object (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 |
#name ⇒ Object (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_default ⇒ Object
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_markdown ⇒ Object
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 |