Module: Banjo

Defined in:
lib/banjo.rb,
lib/banjo/channel.rb,
lib/banjo/version.rb

Defined Under Namespace

Classes: Channel

Constant Summary collapse

VERSION =
"0.0.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.tempoObject

Returns the value of attribute tempo.



12
13
14
# File 'lib/banjo.rb', line 12

def tempo
  @tempo
end

Class Method Details

.load_channelsObject



15
16
17
18
19
# File 'lib/banjo.rb', line 15

def self.load_channels
  Dir['./channels/*.rb'].each do |file|
    load file
  end
end

.playObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/banjo.rb', line 21

def self.play
  tempo_in_ms = 60.0 / Banjo.tempo / 16

  EventMachine.run do
    n = 0
    EM.add_periodic_timer(tempo_in_ms) do
      begin
        Banjo.load_channels
      end

      Banjo::Channel.channels.each do |klass|
        channel = klass.new(n)
        channel.perform
      end

      n < 15 ? n += 1 : n = 0
    end

    puts "Banjo Reactor started..."
  end
end