Class: UPnPStateVariable

Inherits:
UPnPModel show all
Defined in:
lib/upnp_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from UPnPModel

define_xml_attr, to_method_name

Instance Attribute Details

#data_typeObject

Returns the value of attribute data_type.



380
381
382
# File 'lib/upnp_model.rb', line 380

def data_type
  @data_type
end

#multicastObject

Returns the value of attribute multicast.



380
381
382
# File 'lib/upnp_model.rb', line 380

def multicast
  @multicast
end

#nameObject

Returns the value of attribute name.



380
381
382
# File 'lib/upnp_model.rb', line 380

def name
  @name
end

#send_eventsObject

Returns the value of attribute send_events.



380
381
382
# File 'lib/upnp_model.rb', line 380

def send_events
  @send_events
end

Class Method Details

.read_xml_node(node) ⇒ Object



406
407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/upnp_model.rb', line 406

def UPnPStateVariable.read_xml_node(node)
  state_variable = UPnPStateVariable.new
  state_variable.send_events = node.attribute('sendEvents')
  state_variable.multicast = node.attribute('multicast')
  node.elements.each do |elem|
    case elem.name
    when 'name'
      state_variable.name = elem.text
    when 'dataType'
      state_variable.data_type = elem.text
    end
  end
  return state_variable
end

Instance Method Details

#to_sObject



382
383
384
# File 'lib/upnp_model.rb', line 382

def to_s
  "State Variable -- #{@name} (data type: '#{@data_type}' send events? '#{@send_events}' multicast? '#{@multicast}')"
end

#to_xmlObject



386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/upnp_model.rb', line 386

def to_xml
  state_variable = XmlTag.new 'stateVariable'
  if @send_events != nil
    state_variable.attributes['sendEvents'] = @send_events
  end

  if @multicast != nil
    state_variable.attributes['multicast'] = @multicast
  end
  
  prop = state_variable.append XmlTag.new 'name'
  prop.append XmlText.new @name

  prop = state_variable.append XmlTag.new 'dataType'
  prop.append XmlText.new @data_type
  
  return state_variable.to_s
end