Class: Hindbaer::AudioPool

Inherits:
Object
  • Object
show all
Defined in:
lib/hindbaer/audio_pool.rb

Constant Summary collapse

ATTRIBUTES =
%w{
path location
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ AudioPool

Returns a new instance of AudioPool.



23
24
25
26
27
# File 'lib/hindbaer/audio_pool.rb', line 23

def initialize(&block)
  self.files = []
  
  block.arity > 0 ? block.call(self) : instance_eval(&block)
end

Instance Attribute Details

#filesObject

Returns the value of attribute files.



9
10
11
# File 'lib/hindbaer/audio_pool.rb', line 9

def files
  @files
end

Class Method Details

.parse(doc) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/hindbaer/audio_pool.rb', line 11

def self.parse(doc)
  new do
    ATTRIBUTES.each do |attribute|
      self.send("#{attribute.to_sym}=", doc[attribute.capitalize])
    end
    
    self.files = doc.css('File').map do |f|
      Hindbaer::File.parse(f)
    end
  end
end

Instance Method Details

#to_xml(xml) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/hindbaer/audio_pool.rb', line 29

def to_xml(xml)
  xml.AudioPool Path: path, Location: location do
    files.each do |file|
      file.to_xml(xml)
    end
  end
end