class FFI::Extractor::PluginList

Represents the list of loaded extractor plugins.

Public Class Methods

default(policy=:default) click to toggle source

Loads the installed extractor plugins.

@param [Symbol] policy

The policy for how the plugins will be ran.

@return [PluginList]

The loaded plugins.

@raise [LoadError]

The no plugins were loaded.
# File lib/ffi/extractor/plugin_list.rb, line 62
def self.default(policy=:default)
  ptr = Extractor.EXTRACTOR_plugin_add_defaults(policy)

  if ptr.null?
    raise(LoadError,"no plugins were loaded")
  end

  return new(ptr)
end
new(ptr=FFI::Pointer.new(0)) click to toggle source

Initializes the plugin list.

@param [FFI::Pointer] ptr

The pointer to the list.
# File lib/ffi/extractor/plugin_list.rb, line 36
def initialize(ptr=FFI::Pointer.new(0))
  @ptr = ptr
end
release(ptr) click to toggle source

Releases the plugin list.

@param [FFI::Pointer] ptr

The pointer to the list.
# File lib/ffi/extractor/plugin_list.rb, line 46
def self.release(ptr)
  Extractor.EXTRACTOR_plugin_remove_all(ptr)
end

Public Instance Methods

add(name,options='',policy=:default) click to toggle source

Loads a plugin and adds it to the list.

@param [Symbol] name

The plugin name.

@param [String] options

Options for the plugin.

@param [Symbol] policy

The policy for how the plugin will be ran.

@return [PluginList]

The modified plugin list.

@raise [LoadError]

The plugin could not be loaded.
# File lib/ffi/extractor/plugin_list.rb, line 90
def add(name,options='',policy=:default)
  name    = name.to_s
  new_ptr = Extractor.EXTRACTOR_plugin_add(@ptr,name,options,policy)

  if new_ptr == @ptr
    raise(LoadError,"could not add #{name.dump} to the plugin list")
  end

  @ptr = new_ptr
  return self
end
clear()
Alias for: remove_all
delete(name)
Alias for: remove
remove(name) click to toggle source

Removes a plugin from the list.

@param [Symbol] name

The plugin name.

@return [PluginList]

The modified plugin list.

@raise [ArgumentError]

The plugin could not be found in the list.
# File lib/ffi/extractor/plugin_list.rb, line 114
def remove(name)
  name    = name.to_s
  new_ptr = Extractor.EXTRACTOR_plugin_remove(@ptr,name)

  if new_ptr == @ptr
    raise(ArgumentError,"could not remove #{name.dump} from the plugin list")
  end

  @ptr = new_ptr
  return self
end
Also aliased as: delete
remove_all() click to toggle source

Removes all plugins from the list.

@return [PluginList]

The empty plugin list.
# File lib/ffi/extractor/plugin_list.rb, line 134
def remove_all
  Extractor.EXTRACTOR_plugin_remove_all(@ptr)
  return self
end
Also aliased as: clear
to_ptr() click to toggle source

Converts the plugin list to a pointer.

@return [FFI::Pointer]

The pointer to the plugin list.
# File lib/ffi/extractor/plugin_list.rb, line 147
def to_ptr
  @ptr
end