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.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rsence/plugins/guiparser.rb', line 43 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
61 62 63 64 |
# File 'lib/rsence/plugins/guiparser.rb', line 61 def kill( msg ) # gui_name = @parent.name msg.reply( "RSence.killGuiTree(#{@gui_name.to_json});" ) end |
#struct(msg, params) ⇒ Object
include ::RSence
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rsence/plugins/guiparser.rb', line 23 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.
67 68 69 70 71 72 73 74 75 |
# File 'lib/rsence/plugins/guiparser.rb', line 67 def values( ses ) ids = {} ses.each do | key, value | if value.class == HValue ids[ key ] = value.value_id end end return ids end |