Class: RSence::Plugins::GUIParser
- Inherits:
-
Object
- Object
- RSence::Plugins::GUIParser
- Defined in:
- lib/rsence/plugins/guiparser.rb
Overview
This class automatically loads a YAML file from “gui” subdirectory of a plugin.
Extend your plugin from the GUIPlugin class instead of the Plugin class to make this work automatically.
Instance Method Summary collapse
-
#init(msg, params) ⇒ Object
Use this method to send the client all commands required to construct the GUI Tree using JSONRenderer.
- #kill(msg) ⇒ Object
-
#struct(msg, params) ⇒ Object
include ::RSence.
-
#values(ses) ⇒ Object
Use this method to extract all the value id’s of the
ses
hash.
Instance Method Details
#init(msg, params) ⇒ Object
Use this method to send the client all commands required to construct the GUI Tree using JSONRenderer.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rsence/plugins/guiparser.rb', line 51 def init( msg, params ) gui_data = struct( msg, params ) if gui_data.class == Array gui_data = { 'type' => 'GUITree', 'version' => 0.9, 'class' => 'RSence.GUIApp', 'options' => { 'priority' => 0, 'label' => "#{@gui_name.capitalize} (autogenerated)" }, 'subviews' => gui_data } end json_data = JSON.dump( gui_data ) msg.reply( "RSence.guiTrees[#{@gui_name.to_json}]=JSONRenderer.nu(#{json_data});", true ) end |
#kill(msg) ⇒ Object
69 70 71 72 |
# File 'lib/rsence/plugins/guiparser.rb', line 69 def kill( msg ) # gui_name = @parent.name msg.reply( "RSence.killGuiTree(#{@gui_name.to_json});" ) end |
#struct(msg, params) ⇒ Object
include ::RSence
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rsence/plugins/guiparser.rb', line 31 def struct( msg, params ) gui_data = YAML.load( @yaml_src ) parse_gui( gui_data, params ) return gui_data if gui_data.class == Array if gui_data.has_key?('dependencies') @parent.include_js( msg, gui_data['dependencies'] ) gui_data.delete('dependencies') end if gui_data.has_key?('include') gui_data['include'].each do | js_file | js_src = @parent.read_js_once( msg, js_file ) msg.reply( js_src ) end end return gui_data end |
#values(ses) ⇒ Object
Use this method to extract all the value id’s of the ses
hash.
75 76 77 78 79 80 81 82 83 |
# File 'lib/rsence/plugins/guiparser.rb', line 75 def values( ses ) ids = {} ses.each do | key, value | if value.class == HValue ids[ key ] = value.value_id end end return ids end |