class UPnPScpd
Attributes
actions[RW]
spec_version[RW]
state_variables[RW]
Public Class Methods
new()
click to toggle source
# File lib/upnp_model.rb, line 219 def initialize @actions = [] @state_variables = [] end
read(xml)
click to toggle source
# File lib/upnp_model.rb, line 252 def UPnPScpd.read(xml) scpd = UPnPScpd.new doc = Nokogiri::XML(xml) doc.root.elements.each do |elem| case elem.name when 'specVersion' scpd.spec_version = [1,0] when 'actionList' elem.elements.each { |action_node| if action_node.name == 'action' action = UPnPAction.read_xml_node(action_node) scpd.actions << action end } when 'serviceStateTable' elem.elements.each { |state_variable_node| if state_variable_node.name == 'stateVariable' state_variable = UPnPStateVariable.read_xml_node(state_variable_node) scpd.state_variables << state_variable end } end end return scpd end
to_xml_doc(scpd)
click to toggle source
# File lib/upnp_model.rb, line 248 def UPnPScpd.to_xml_doc(scpd) return '<?xml version="1.0" encoding="UTF-8"?>' + "\n#{scpd.to_xml}" end
Public Instance Methods
to_xml()
click to toggle source
# File lib/upnp_model.rb, line 226 def to_xml scpd = XmlTag.new 'scpd' scpd.attributes['xmlns'] = 'urn:schemas-upnp-org:service-1-0' spec_version = scpd.append XmlTag.new('specVersion') spec_version.append(XmlTag.new('major')).append(XmlText.new(1)) spec_version.append(XmlTag.new('minor')).append(XmlText.new(0)) action_list = scpd.append XmlTag.new('actionList') @actions.each { |action| action_list.append action.to_xml } service_state_table = scpd.append XmlTag.new('serviceStateTable'); @state_variables.each { |state_variable| service_state_table.append state_variable.to_xml } return scpd.to_s end