Class: Hindbaer::Region

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

Constant Summary collapse

ATTRIBUTES =
%w{
  ref name start offset length fade_in fade_out gain leq dynamics
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Region

Returns a new instance of Region.



28
29
30
31
32
# File 'lib/hindbaer/region.rb', line 28

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

Instance Attribute Details

#fadesObject

Returns the value of attribute fades.



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

def fades
  @fades
end

Class Method Details

.parse(fragment) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hindbaer/region.rb', line 11

def self.parse(fragment)
  new do
    ATTRIBUTES.each do |attribute|
      self.send(
      "#{attribute.to_sym}=",   
      fragment[attribute.split('_').map(&:capitalize).join]
      )
      
      self.start = '00.0' unless start
      
      self.fades = fragment.css('Fade').map do |f|
        Hindbaer::Fade.parse(f)
      end
    end
  end
end