Class: AnnotateRb::ModelAnnotator::ForeignKeyAnnotation::ForeignKeyComponent

Inherits:
Components::Base
  • Object
show all
Defined in:
lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Components::Base

#to_rdoc, #to_yard

Constructor Details

#initialize(formatted_name, constraints_info, ref_info, max_size) ⇒ ForeignKeyComponent

Returns a new instance of ForeignKeyComponent.



9
10
11
12
13
14
# File 'lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb', line 9

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

Instance Attribute Details

#constraints_infoObject (readonly)

Returns the value of attribute constraints_info.



7
8
9
# File 'lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb', line 7

def constraints_info
  @constraints_info
end

#formatted_nameObject (readonly)

Returns the value of attribute formatted_name.



7
8
9
# File 'lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb', line 7

def formatted_name
  @formatted_name
end

#max_sizeObject (readonly)

Returns the value of attribute max_size.



7
8
9
# File 'lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb', line 7

def max_size
  @max_size
end

#ref_infoObject (readonly)

Returns the value of attribute ref_info.



7
8
9
# File 'lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb', line 7

def ref_info
  @ref_info
end

Instance Method Details

#to_defaultObject



23
24
25
26
27
28
29
30
# File 'lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb', line 23

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

#to_markdownObject



16
17
18
19
20
21
# File 'lib/annotate_rb/model_annotator/foreign_key_annotation/foreign_key_component.rb', line 16

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