Class: YARD::Tags::TypesExplainer

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/tags/types_explainer.rb

Class Method Summary collapse

Class Method Details

.explain(*types) ⇒ String?

Provides a plain English summary of the type specification, or nil if no types are provided or parseable.

Parameters:

  • types (Array<String>)

    a list of types to parse and summarize

Returns:

  • (String)

    a plain English description of the associated types

  • (nil)

    if no types are provided or not parseable



9
10
11
12
13
# File 'lib/yard/tags/types_explainer.rb', line 9

def self.explain(*types)
  explain!(*types)
rescue SyntaxError
  nil
end

.explain!(*types) ⇒ String?

Provides a plain English summary of the type specification, or nil if no types are provided or parseable.

Parameters:

  • types (Array<String>)

    a list of types to parse and summarize

Returns:

  • (String)

    a plain English description of the associated types

  • (nil)

    if no types are provided or not parseable

Raises:

  • (SyntaxError)

    if the types are not parseable



17
18
19
# File 'lib/yard/tags/types_explainer.rb', line 17

def self.explain!(*types)
  Parser.parse(types.join(", ")).join("; ")
end