Class: BigBlueButton::BigBlueButtonConfigLayout
- Inherits:
-
Object
- Object
- BigBlueButton::BigBlueButtonConfigLayout
- Defined in:
- lib/bigbluebutton_config_layout.rb
Overview
A helper class to work with layout definition files. You set an xml file on it (usually obtained from a property of in the XML obtained from BigBlueButtonApi#get_default_config_xml), use it to work with the layouts, and then get the new xml from this class.
Usage example:
xml = api.get_default_config_xml
config_xml = BigBlueButton::BigBlueButtonConfigXml.new(xml)
url = config_xml.get_attribute("LayoutModule", "layoutConfig", true)
# send a request to 'url' to fetch the xml file into 'response'
layout_config = BigBlueButton::BigBlueButtonConfigLayout.new(response)
layout_config.get_available_layouts
Instance Attribute Summary collapse
-
#xml ⇒ Object
Returns the value of attribute xml.
Instance Method Summary collapse
-
#get_available_layouts ⇒ Object
Returns an array with the name of each layout available in the XML.
-
#initialize(xml) ⇒ BigBlueButtonConfigLayout
constructor
- xml (string)
-
The XML that has the definition of all layouts, usually fetched from the web conference server.
Constructor Details
#initialize(xml) ⇒ BigBlueButtonConfigLayout
- xml (string)
-
The XML that has the definition of all layouts, usually fetched from the web conference server.
26 27 28 29 30 31 32 33 34 |
# File 'lib/bigbluebutton_config_layout.rb', line 26 def initialize(xml) @xml = nil opts = { 'ForceArray' => false, 'KeepRoot' => true } begin @xml = XmlSimple.xml_in(xml, opts) rescue Exception => e raise BigBlueButton::BigBlueButtonException.new("Error parsing the layouts XML. Error: #{e.}") end end |
Instance Attribute Details
#xml ⇒ Object
Returns the value of attribute xml.
22 23 24 |
# File 'lib/bigbluebutton_config_layout.rb', line 22 def xml @xml end |
Instance Method Details
#get_available_layouts ⇒ Object
Returns an array with the name of each layout available in the XML. Will return only unique names, ordered the way they are ordered in the XML. Returns nil if the XML is not properly formatted and an empty array if there are no layouts in the file.
40 41 42 43 44 45 46 |
# File 'lib/bigbluebutton_config_layout.rb', line 40 def get_available_layouts if xml_has_layouts xml["layouts"]["layout"].map{ |l| l["name"] }.uniq else nil end end |