Class: Watobo::PluginBase
- Inherits:
-
Object
- Object
- Watobo::PluginBase
- Defined in:
- lib/watobo/gui/templates/plugin_base.rb
Overview
:nodoc: all
Class Method Summary collapse
- .create_gui ⇒ Object
- .gui ⇒ Object
- .has_gui? ⇒ Boolean
- .inherited(subclass) ⇒ Object
- .load_gui(*order) ⇒ Object
- .load_libs(*order) ⇒ Object
Class Method Details
.create_gui ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/watobo/gui/templates/plugin_base.rb', line 36 def self.create_gui() if self.const_defined? :Gui gui = self.class_eval("Gui") @gui = gui.new() return @gui end puts "No GUI available for #{self}!" return nil end |
.gui ⇒ Object
31 32 33 |
# File 'lib/watobo/gui/templates/plugin_base.rb', line 31 def self.gui @gui end |
.has_gui? ⇒ Boolean
66 67 68 69 |
# File 'lib/watobo/gui/templates/plugin_base.rb', line 66 def self.has_gui? puts self return true end |
.inherited(subclass) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/watobo/gui/templates/plugin_base.rb', line 4 def self.inherited(subclass) %w( plugin_name plugin_path description version author output_path config_path lib_path ).each do |cvar| define_method(cvar) { self.class.instance_variable_get("@#{cvar}") } define_singleton_method("get_#{cvar}") { return nil unless instance_variable_defined?("@#{cvar}") instance_variable_get("@#{cvar}") } define_singleton_method("#{cvar}") { |val| instance_variable_set("@#{cvar}", val) } end path = File.join(File.dirname(caller[0])) subclass.plugin_path path if File.exist?(path) lpath = File.join(path, "lib") subclass.lib_path lpath if File.exist?(lpath) end |
.load_gui(*order) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/watobo/gui/templates/plugin_base.rb', line 47 def self.load_gui(*order) # load if WATOBO is in GUI mode if Watobo.const_defined? :Gui # gui_path = File.join(File.dirname(caller[0]), "gui") gui_path = File.join(get_plugin_path, "gui") if order.empty? libs = Dir.glob("#{gui_path}/*") else libs = order.map { |l| l.to_s + ".rb" } end libs.each do |lib| puts "loading gui-lib #{lib} ..." load File.join(gui_path, lib) end else puts "WATOBO NOT IN GUI MODE!" end end |
.load_libs(*order) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/watobo/gui/templates/plugin_base.rb', line 19 def self.load_libs(*order) lpath = get_lib_path if order.empty? libs = Dir.glob("#{lpath}/*") else libs = order.map { |l| l.to_s + ".rb" } end libs.each do |lib| load File.join(lib) end end |