Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added song

  • Loading branch information...
commit 9ccf9c81d0573860ce72c7b96bf22f21153c49b6 1 parent 6803117
@rafadc rafadc authored
Showing with 35 additions and 0 deletions.
  1. +17 −0 lib/model/song.rb
  2. +1 −0  rhythmic.rb
  3. +17 −0 spec/song_spec.rb
View
17 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
View
1  rhythmic.rb
@@ -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."
View
17 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
Please sign in to comment.
Something went wrong with that request. Please try again.