Class: Hindbaer::Track
- Inherits:
-
Object
- Object
- Hindbaer::Track
- Defined in:
- lib/hindbaer/track.rb
Constant Summary collapse
- ATTRIBUTES =
%w{ name pan }
Instance Attribute Summary collapse
-
#plugins ⇒ Object
Returns the value of attribute plugins.
-
#regions ⇒ Object
Returns the value of attribute regions.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(&block) ⇒ Track
constructor
A new instance of Track.
- #to_xml(xml) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Track
Returns a new instance of Track.
26 27 28 29 30 31 |
# File 'lib/hindbaer/track.rb', line 26 def initialize(&block) self.regions = [] self.plugins = [] block.arity > 0 ? block.call(self) : instance_eval(&block) end |
Instance Attribute Details
#plugins ⇒ Object
Returns the value of attribute plugins.
9 10 11 |
# File 'lib/hindbaer/track.rb', line 9 def plugins @plugins end |
#regions ⇒ Object
Returns the value of attribute regions.
9 10 11 |
# File 'lib/hindbaer/track.rb', line 9 def regions @regions end |
Class Method Details
.parse(doc) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/hindbaer/track.rb', line 11 def self.parse(doc) new do ATTRIBUTES.each do |attribute| self.send("#{attribute.to_sym}=", doc[attribute.capitalize]) end self.regions = doc.css('Region').map do |r| Hindbaer::Region.parse(r) end self.plugins = doc.css('Plugin').map do |p| Hindbaer::Plugin.parse(p) end end end |
Instance Method Details
#to_xml(xml) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/hindbaer/track.rb', line 33 def to_xml(xml) xml.Track Name: name, Pan: pan do regions.each do |region| xml.Region Ref: region.ref, Name: region.name, Start: region.start, Length: region.length, Offset: region.offset, FadeIn: region.fade_in, FadeOut: region.fade_out, Gain: region.gain, Leq: region.leq do region.fades.each do |fade| fade.to_xml(xml) end end end unless plugins.empty? xml.Plugins do plugins.each do |plugin| plugin.to_xml(xml) end end end end end |