# Class: YARD::Tags::TypesExplainer

Inherits:
  Object
  - Object
  - YARD::Tags::TypesExplainer
  show all

Defined in:
  lib/yard/tags/types_explainer.rb

## Constant Summary collapse

LITERALMATCH =

Regular expression to match symbol and string literals

      /:\w+|'[^']*'|"[^"]*"/

## Class Method Summary collapse

- .explain(*types) ⇒ String?

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

- .explain!(*types) ⇒ String?

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

## Class Method Details

### .explain(*types) ⇒ `String`?

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

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 parsable

    12
    13
    14
    15
    16

    # File 'lib/yard/tags/types_explainer.rb', line 12

    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 parsable.

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 parsable

Raises:

- (`SyntaxError`) —

  if the types are not parsable

    20
    21
    22

    # File 'lib/yard/tags/types_explainer.rb', line 20

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