Class: AnnotateRb::ModelAnnotator::EnumAnnotation::EnumComponent

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Components::Base

#to_rdoc, #to_yard

Constructor Details

#initialize(name, values, max_size) ⇒ EnumComponent

Returns a new instance of EnumComponent.



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

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

Instance Attribute Details

#max_sizeObject (readonly)

Returns the value of attribute max_size.



7
8
9
# File 'lib/annotate_rb/model_annotator/enum_annotation/enum_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/enum_annotation/enum_component.rb', line 7

def name
  @name
end

#valuesObject (readonly)

Returns the value of attribute values.



7
8
9
# File 'lib/annotate_rb/model_annotator/enum_annotation/enum_component.rb', line 7

def values
  @values
end

Instance Method Details

#to_defaultObject



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

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

#to_markdownObject



21
22
23
# File 'lib/annotate_rb/model_annotator/enum_annotation/enum_component.rb', line 21

def to_markdown
  sprintf("# * `%s`: `%s`", name, values.join(", "))
end