123456789_123456789_123456789_123456789_123456789_

Module: YARD::Templates::Helpers::UMLHelper

Relationships & Source Files
Defined in: lib/yard/templates/helpers/uml_helper.rb

Overview

::YARD::Templates::Helpers for UML template format

Instance Method Summary

Instance Method Details

#format_path(object) ⇒ String

Formats the path of an object for Graphviz syntax

Parameters:

Returns:

  • (String)

    the encoded path

[ GitHub ]

  
# File 'lib/yard/templates/helpers/uml_helper.rb', line 20

def format_path(object)
  object.path.gsub('::', '_')
end

#h(text) ⇒ String

Encodes text in escaped Graphviz syntax

Parameters:

  • text (String)

    text to encode

Returns:

  • (String)

    the encoded text

[ GitHub ]

  
# File 'lib/yard/templates/helpers/uml_helper.rb', line 27

def h(text)
  text.to_s.gsub(/(\W)/, '\\\\\1')
end

#tidy(data) ⇒ String

Tidies data by formatting and indenting text

Parameters:

  • data (String)

    pre-formatted text

Returns:

[ GitHub ]

  
# File 'lib/yard/templates/helpers/uml_helper.rb', line 34

def tidy(data)
  indent = 0
  data.split(/\n/).map do |line|
    line.gsub!(/^\s*/, '')
    next if line.empty?
    indent -= 1 if line =~ /^\s*\}\s*$/
    line = (' ' * (indent * 2)) + line
    indent += 1 if line =~ /\{\s*$/
    line
  end.compact.join("\n") + "\n"
end

#uml_visibility(object) ⇒ String

Official UML visibility prefix syntax for an object given its visibility

Parameters:

Returns:

  • (String)

    the UML visibility prefix

[ GitHub ]

  
# File 'lib/yard/templates/helpers/uml_helper.rb', line 9

def uml_visibility(object)
  case object.visibility
  when :public;    '+'
  when :protected; '#'
  when :private;   '-'
  end
end