Class: BigBlueButton::BigBlueButtonConfigXml
- Inherits:
-
Object
- Object
- BigBlueButton::BigBlueButtonConfigXml
- Defined in:
- lib/bigbluebutton_config_xml.rb
Overview
A helper class to work with config.xml files. You set an xml file on it (usually obtained via BigBlueButtonApi#get_default_config_xml), use it to modify this xml, and then get the new xml from this class (usually to set in the server using BigBlueButtonApi#set_config_xml).
Usage example:
xml = api.get_default_config_xml
config_xml = BigBlueButton::BigBlueButtonConfigXml.new(xml)
# change the xml a bit
config_xml.set_attribute("skinning", "enabled", "false", false)
config_xml.set_attribute("layout", "defaultLayout", "Webinar", false)
config_xml.set_attribute("layout", "showLayoutTools", "false", false)
# set the new xml in the server
api.set_config_xml("meeting-id", config_xml)
Instance Attribute Summary collapse
-
#xml ⇒ Object
Returns the value of attribute xml.
Instance Method Summary collapse
- #as_string ⇒ Object
- #get_attribute(finder, attr_name, is_module = true) ⇒ Object
-
#initialize(xml) ⇒ BigBlueButtonConfigXml
constructor
A new instance of BigBlueButtonConfigXml.
- #is_modified? ⇒ Boolean
- #set_attribute(finder, attr_name, value, is_module = true) ⇒ Object
Constructor Details
#initialize(xml) ⇒ BigBlueButtonConfigXml
Returns a new instance of BigBlueButtonConfigXml.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bigbluebutton_config_xml.rb', line 27 def initialize(xml) @original_string = nil @xml = nil unless xml.nil? opts = { 'ForceArray' => false, 'KeepRoot' => true } begin @xml = XmlSimple.xml_in(xml, opts) @original_string = self.as_string.clone rescue Exception => e exception = BigBlueButton::BigBlueButtonException.new("Error parsing the config XML. Error: #{e.}") exception.key = 'XMLParsingError' raise exception end end end |
Instance Attribute Details
#xml ⇒ Object
Returns the value of attribute xml.
25 26 27 |
# File 'lib/bigbluebutton_config_xml.rb', line 25 def xml @xml end |
Instance Method Details
#as_string ⇒ Object
75 76 77 |
# File 'lib/bigbluebutton_config_xml.rb', line 75 def as_string XmlSimple.xml_out(@xml, { 'RootName' => nil, 'XmlDeclaration' => false, 'NoIndent' => true }) end |
#get_attribute(finder, attr_name, is_module = true) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bigbluebutton_config_xml.rb', line 43 def get_attribute(finder, attr_name, is_module=true) if is_module tag = find_module(finder) else tag = find_tag(finder) end if tag find_attribute(tag, attr_name) else nil end end |
#is_modified? ⇒ Boolean
79 80 81 82 |
# File 'lib/bigbluebutton_config_xml.rb', line 79 def is_modified? @xml and self.as_string != @original_string end |
#set_attribute(finder, attr_name, value, is_module = true) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/bigbluebutton_config_xml.rb', line 56 def set_attribute(finder, attr_name, value, is_module=true) if is_module tag = find_module(finder) else tag = find_tag(finder) end if tag attr = find_attribute(tag, attr_name) if attr # saves always as string tag[attr_name] = value.is_a?(String) ? value : value.to_s else nil end else nil end end |