class Processing::LibraryLoader

Encapsulate library loader functionality as a class

Attributes

library[R]

Public Class Methods

new() click to toggle source
# File lib/jruby_art/library_loader.rb, line 11
def initialize
  @loaded_libraries = Hash.new(false)
end

Public Instance Methods

library_loaded?(library_name) click to toggle source

Detect if a library has been loaded (for conditional loading)

# File lib/jruby_art/library_loader.rb, line 16
def library_loaded?(library_name)
  @loaded_libraries[library_name.to_sym]
end
load_jars(lib, name) click to toggle source
# File lib/jruby_art/library_loader.rb, line 46
def load_jars(lib, name)
  lib.load_jars
  @loaded_libraries[name] = true
end
load_libraries(*args) click to toggle source

Load a list of Ruby or Java libraries (in that order) Usage: load_libraries :video, :video_event

If a library is put into a 'library' folder next to the sketch it will be used instead of the library that ships with vanilla processing (or ide installed), or JRubyArt.

# File lib/jruby_art/library_loader.rb, line 25
def load_libraries(*args)
  message = 'no such file to load -- %s'
  args.each do |lib|
    loaded = loader(lib)
    raise(LoadError.new, format(message, lib)) unless loaded
  end
end
Also aliased as: load_library
load_library(*args)
Alias for: load_libraries
loader(name) click to toggle source
# File lib/jruby_art/library_loader.rb, line 34
def loader(name)
  return true if @loaded_libraries.include?(name)

  fname = name.to_s
  library = Library.new(fname)
  library.locate
  return require_library(library, name) if library.ruby?

  warn("Not found library: #{fname}") unless library.exist?
  load_jars(library, name)
end
require_library(lib, name) click to toggle source
# File lib/jruby_art/library_loader.rb, line 51
def require_library(lib, name)
  @loaded_libraries[name] = require lib.path
end