Class: AnnotateRb::ModelAnnotator::Annotation::MarkdownHeader

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

Constant Summary collapse

MD_NAMES_OVERHEAD =
6
MD_TYPE_ALLOWANCE =
18

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Components::Base

#to_rdoc, #to_yard

Constructor Details

#initialize(max_size) ⇒ MarkdownHeader

Returns a new instance of MarkdownHeader.



12
13
14
# File 'lib/annotate_rb/model_annotator/annotation/markdown_header.rb', line 12

def initialize(max_size)
  @max_size = max_size
end

Instance Attribute Details

#max_sizeObject (readonly)

Returns the value of attribute max_size.



10
11
12
# File 'lib/annotate_rb/model_annotator/annotation/markdown_header.rb', line 10

def max_size
  @max_size
end

Instance Method Details

#to_defaultObject



33
34
35
# File 'lib/annotate_rb/model_annotator/annotation/markdown_header.rb', line 33

def to_default
  nil
end

#to_markdownObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/annotate_rb/model_annotator/annotation/markdown_header.rb', line 16

def to_markdown
  name_padding = max_size + MD_NAMES_OVERHEAD
  # standard:disable Lint/FormatParameterMismatch
  formatted_headers = format("# %-#{name_padding}.#{name_padding}s | %-#{MD_TYPE_ALLOWANCE}.#{MD_TYPE_ALLOWANCE}s | %s",
    "Name",
    "Type",
    "Attributes")
  # standard:enable Lint/FormatParameterMismatch

  <<~HEADER.strip
    # ### Columns
    #
    #{formatted_headers}
    # #{"-" * name_padding} | #{"-" * MD_TYPE_ALLOWANCE} | #{"-" * 27}
  HEADER
end