class FFI::Extractor::MetadataProcessor

Constants

PLUGIN_NAMES

Mapping of plugin paths to names

Public Class Methods

new() { |PLUGIN_NAMES, type, format, mime_type, value| ... } click to toggle source

Wraps a Metadata Processor callback.

@yield [plugin_name, type, format, mime_type, data]

The given block will be passed the extracted metadata.

@yieldparam [Symbol] plugin_name

The name of the plugin.

@yieldparam [Symbol] type

The type of metadata.

@yieldparam [:unknown, :utf8, :binary, :c_string] format

The format of the metadata.

@yieldparam [String] mime_type

The MIME-type of the data.

@yieldparam [String, FFI::Pointer] data

The extracted metadata. If the `type` is `:unknown`, the original
`FFI::Pointer` object will be yielded.

@return [Proc]

The wrapped callback.
Calls superclass method
# File lib/ffi/extractor/metadata_processor.rb, line 59
def self.new(&block)
  super do |cls,plugin,type,format,mime_type,data,size|
    catch(:return) {
      value = case format
              when :c_string, :utf8 then data.get_string(0,size)
              when :binary          then data.get_bytes(0,size)
              else                       data
              end

      yield PLUGIN_NAMES[plugin], type, format, mime_type, value

      0
    }
  end
end