# Class: YARD::Handlers::Ruby::MethodHandler

Inherits:
  Base
  - Object
  - Handlers::Base
  - Base
  - YARD::Handlers::Ruby::MethodHandler
  show all

Includes:
  Common::MethodHandler

Defined in:
  lib/yard/handlers/ruby/method_handler.rb

## Overview

Handles a method definition

## Instance Method Summary collapse

- #format_args ⇒ Object

### Methods included from Common::MethodHandler

#add_predicate_return_tag

### Methods included from Parser::Ruby

#s

## Instance Method Details

### #format_args ⇒ `Object`

    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103

    # File 'lib/yard/handlers/ruby/method_handler.rb', line 69

    def format_args
      return [] unless args = statement.parameters

      params = []

      if args.unnamed_required_params
        params += args.unnamed_required_params.map {|a| [a.source, nil] }
      end

      if args.unnamed_optional_params
        params += args.unnamed_optional_params.map do |a|
          [a[0].source, a[1].source]
        end
      end

      params << ['*' + args.splat_param.source, nil] if args.splat_param

      if args.unnamed_end_params
        params += args.unnamed_end_params.map {|a| [a.source, nil] }
      end

      if args.named_params
        params += args.named_params.map do |a|
          [a[0].source, a[1] ? a[1].source : nil]
        end
      end

      if args.double_splat_param
        params << ['**' + args.double_splat_param.source, nil]
      end

      params << ['&' + args.block_param.source, nil] if args.block_param && !args.args_forward

      params
    end