Class: UpnpContentExplorer::Item
- Inherits:
-
Object
- Object
- UpnpContentExplorer::Item
- Defined in:
- lib/upnp_content_explorer/item.rb
Instance Method Summary collapse
-
#initialize(xml_node) ⇒ Item
constructor
A new instance of Item.
- #metadata ⇒ Object
Constructor Details
#initialize(xml_node) ⇒ Item
Returns a new instance of Item.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/upnp_content_explorer/item.rb', line 3 def initialize(xml_node) @xml_node = xml_node @props = {} %w{id parentID restricted}.each do |m| define_singleton_method(m) { extract_xpath("@#{m}") } end %w{title class date}.each do |m| define_singleton_method(m) { extract_xpath("#{m}") } end @metadata = {} %w{ size duration bitrate sampleFrequency nrAudioChannels resolution protocolInfo }.each do |m| v = extract_xpath("res/@#{m}") @metadata[m.to_sym] = v define_singleton_method(m) { v } end @metadata[:url] = extract_xpath('res') @metadata[:itemClass] = extract_xpath('class') %w{url itemClass}.each do |m| define_singleton_method(m) { @metadata[m.to_sym] } end end |
Instance Method Details
#metadata ⇒ Object
33 34 35 |
# File 'lib/upnp_content_explorer/item.rb', line 33 def {}.merge(@metadata) end |