Class: Radio::Signal::File

Inherits:
Object
  • Object
show all
Defined in:
lib/radio/signals/wav.rb,
lib/radio/signals/file.rb

Defined Under Namespace

Classes: WAV

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ File

You can load any file, not just the ones in sources.



45
46
47
48
49
50
51
52
# File 'lib/radio/signals/file.rb', line 45

def initialize options
  self.class.constants.each do |x|
    klass = eval x.to_s
    @reader = klass.new options
    break if @reader
  end
  raise 'Unknown format' unless @reader
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



54
55
56
# File 'lib/radio/signals/file.rb', line 54

def method_missing meth, *args, &block
  @reader.send meth, *args, &block
end

Class Method Details

.devicesObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/radio/signals/file.rb', line 25

def self.devices
  result = {}
  files = Dir.glob ::File.expand_path '../../../../test/wav/**/*.wav', __FILE__
  files.each do |file|
    begin
      f = new id:file, input:[0,1]
    rescue Exception => e
      next
    end
    result[file] = {
      name: file,
      rates: [f.rate],
      input: f.input_channels,
      output: 0
    }
  end
  result
end

.statusObject



21
22
23
# File 'lib/radio/signals/file.rb', line 21

def self.status
  "Loaded: %d files found" % devices.size
end