Method: YARD::Templates::Helpers::BaseHelper#format_types

Defined in:
lib/yard/templates/helpers/base_helper.rb

#format_types(list, brackets = true) ⇒ String

Formats a list of return types for output and links each type.

Examples:

Formatting types

format_types(['String', 'Array']) #=> "(String, Array)"

Formatting types without surrounding brackets

format_types(['String', 'Array'], false) #=> "String, Array"

Parameters:

  • list (Array<String>)

    a list of types

  • brackets (Boolean) (defaults to: true)

    whether to surround the types in brackets

Returns:

  • (String)

    the formatted list of Ruby types



168
169
170
# File 'lib/yard/templates/helpers/base_helper.rb', line 168

def format_types(list, brackets = true)
  list.nil? || list.empty? ? "" : (brackets ? "(#{list.join(", ")})" : list.join(", "))
end