# Class: Plugins — Documentation by YARD 0.8.6.1

Class List Method List File List

# Class: Plugins

Inherits:
  Array
  - Object
  - Array
  - Plugins
  show all
Defined in:
  lib/common/plugins/plugins.rb

## Instance Attribute Summary (collapse)

- - (Object) option_parser readonly

  Returns the value of attribute option_parser.

## Instance Method Summary (collapse)

- - (Plugins) initialize(option_parser = nil) constructor

  A new instance of Plugins.

- - (Object) register(*plugins)

  param Array(Plugin) plugins.

- - (Object) register_plugin(plugin)

  param Plugin plugin.

### Methods inherited from Array

#_grep_

## Constructor Details

### - (`Plugins`) initialize(option_parser = nil)

A new instance of Plugins

    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17

    # File 'lib/common/plugins/plugins.rb', line 7

    def initialize(option_parser = nil)
      if option_parser
        if option_parser.is_a?(CustomOptionParser)
          @option_parser = option_parser
        else
          raise "The parser must be an instance of CustomOptionParser, #{option_parser.class} supplied"
        end
      else
        @option_parser = CustomOptionParser.new
      end
    end

## Instance Attribute Details

### - (`Object`) option_parser (readonly)

Returns the value of attribute option_parser

    5
    6
    7

    # File 'lib/common/plugins/plugins.rb', line 5

    def option_parser
      @option_parser
    end

## Instance Method Details

### - (`Object`) register(*plugins)

param Array(Plugin) plugins

    20
    21
    22
    23
    24

    # File 'lib/common/plugins/plugins.rb', line 20

    def register(*plugins)
      plugins.each do |plugin|
        register_plugin(plugin)
      end
    end

### - (`Object`) register_plugin(plugin)

param Plugin plugin

    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38

    # File 'lib/common/plugins/plugins.rb', line 27

    def register_plugin(plugin)
      if plugin.is_a?(Plugin)
        self << plugin

        # A plugin may not have options
        if plugin_options = plugin.registered_options
          @option_parser.add(plugin_options)
        end
      else
        raise "The argument must be an instance of Plugin, #{plugin.class} supplied"
      end
    end