Class: Libvirt::Spec::Device::Sound
- Inherits:
-
Object
- Object
- Libvirt::Spec::Device::Sound
- Includes:
- Util
- Defined in:
- lib/libvirt/spec/device/sound.rb
Overview
Represents a sound device.
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(xml = nil) ⇒ Sound
constructor
Initializes a new sound device.
-
#load!(xml) ⇒ Object
Attempts to initialize object attributes based on the XML string given.
-
#to_xml(xml = Nokogiri::XML::Builder.new) ⇒ Object
Returns the XML representation of this device.
Methods included from Util
Constructor Details
#initialize(xml = nil) ⇒ Sound
Initializes a new sound device. If an XML string is given, it will be used to attempt to initialize the attributes.
12 13 14 |
# File 'lib/libvirt/spec/device/sound.rb', line 12 def initialize(xml=nil) load!(xml) if xml end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
8 9 10 |
# File 'lib/libvirt/spec/device/sound.rb', line 8 def model @model end |
Instance Method Details
#load!(xml) ⇒ Object
Attempts to initialize object attributes based on the XML string given.
18 19 20 21 22 |
# File 'lib/libvirt/spec/device/sound.rb', line 18 def load!(xml) xml = Nokogiri::XML(xml).root if !xml.is_a?(Nokogiri::XML::Element) try(xml.xpath("//sound[@model]"), :preserve => true) { |result| self.model = result["model"].to_sym } raise_if_unparseables(xml.xpath("//sound/*")) end |
#to_xml(xml = Nokogiri::XML::Builder.new) ⇒ Object
Returns the XML representation of this device.
25 26 27 28 |
# File 'lib/libvirt/spec/device/sound.rb', line 25 def to_xml(xml=Nokogiri::XML::Builder.new) xml.sound(:model => model) xml.to_xml end |