Method: YARD::CodeObjects::NamespaceObject#meths

Defined in:
lib/yard/code_objects/namespace_object.rb

#meths(opts = {}) ⇒ Array<MethodObject>

Returns all methods that match the attributes specified by opts. If no options are provided, returns all methods.

Examples:

Finds all private and protected class methods

namespace.meths(:visibility => [:private, :protected], :scope => :class)
# => [#<yardoc method MyClass.privmeth>, #<yardoc method MyClass.protmeth>]

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :visibility (Array<Symbol>, Symbol) — default: [:public, :private, :protected]

    the visibility of the methods to list. Can be an array or single value.

  • :scope (Array<Symbol>, Symbol) — default: [:class, :instance]

    the scope of the methods to list. Can be an array or single value.

  • :included (Boolean) — default: true

    whether to include mixed in methods in the list.

Returns:


113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/yard/code_objects/namespace_object.rb', line 113

def meths(opts = {})
  opts = SymbolHash[
    :visibility => [:public, :private, :protected],
    :scope => [:class, :instance],
    :included => true
  ].update(opts)

  opts[:visibility] = [opts[:visibility]].flatten
  opts[:scope] = [opts[:scope]].flatten

  ourmeths = children.select do |o|
    o.is_a?(MethodObject) &&
      opts[:visibility].include?(o.visibility) &&
      opts[:scope].include?(o.scope)
  end

  ourmeths + (opts[:included] ? included_meths(opts) : [])
end