Skip to content

Commit

Permalink
Added song
Browse files Browse the repository at this point in the history
  • Loading branch information
rafadc committed Jan 28, 2012
1 parent 6803117 commit 9ccf9c8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/model/song.rb
@@ -0,0 +1,17 @@
module Rhythmic
class Song

def initialize
@playables = []
end

def add(playable)
@playables.push playable
end

def play
@playables.each {|playable| playable.play}

end
end
end
1 change: 1 addition & 0 deletions rhythmic.rb
Expand Up @@ -9,6 +9,7 @@
require "./lib/model/drumkit_loader_yaml"
require "./lib/model/drumkit"
require "./lib/model/sample"
require "./lib/model/song"

if defined?(Rubygame::Sound).nil?
puts "Couldn't load SDL and SDL_Mixer. Are they correcly installed?. Please check https://github.com/rafadc/rythmic for installation instructions."
Expand Down
17 changes: 17 additions & 0 deletions spec/song_spec.rb
@@ -0,0 +1,17 @@
require "rspec"

require_relative("../rhythmic")

describe "Song playing" do

it "should play a drumkit and a loop if added to a song" do
drumkit = double("Drumkit")
loop = double("Loop")
song = Rhythmic::Song.new
song.add drumkit
song.add loop
drumkit.should_receive(:play)
loop.should_receive(:play)
song.play
end
end

0 comments on commit 9ccf9c8

Please sign in to comment.