Class: QML::PluginLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/qml/plugin_loader.rb

Overview

PluginLoader loads Qt C++ plugins and enables you to use your Qt C++ codes from Ruby easily.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PluginLoader #initialize(dir, libname) ⇒ PluginLoader

Returns a new instance of PluginLoader.

Overloads:

  • #initialize(path) ⇒ PluginLoader

    Examples:

    loader = QML::PluginLoader.new('path/to/libhoge.dylib')

    Parameters:

    • path (String|Pathname)

      the library path (may be platform-dependent).

  • #initialize(dir, libname) ⇒ PluginLoader

    Examples:

    loader = QML::PluginLoader.new('path/to', 'hoge')

    Parameters:

    • dir (String|Pathname)

      the library directory.

    • libname (String)

      the platform-independent library name.



21
22
23
24
# File 'lib/qml/plugin_loader.rb', line 21

def initialize(path, libname = nil)
  path = Pathname(path) + self.class.lib_filename(libname) if libname
  initialize_orig(path.to_s)
end

Class Method Details

.lib_filename(libname) ⇒ String

Returns platform-dependent library file name.

Examples:

# on Mac
QML::PluginLoader.lib_filename("hoge") #=> "libhoge.dylib"

Parameters:

  • libname (String)

Returns:

  • (String)

    platform-dependent library file name.



35
36
37
38
39
40
41
42
43
44
# File 'lib/qml/plugin_loader.rb', line 35

def self.lib_filename(libname)
  case
  when Platform::windows?
    "#{libname}.dll"
  when Platform::mac?
    "lib#{libname}.dylib"
  else
    "lib#{libname}.so"
  end
end

Instance Method Details

#instanceQtObjectBase

Loads the plugin and returns the instance of the plugin.

Returns:



# File 'lib/qml/plugin_loader.rb', line 26