Skip to content

Commit

Permalink
What was I thinking?
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Voorhis committed Nov 11, 2008
1 parent 603651b commit 69528b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/music/csound.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ def write(timeline_or_score)

private
def write_functions(file)
return if @functions.empty?
@functions.each do |(n, t, sz, f, *args)|
file.write("f %i\t%i\t%i\t%i%s\n" % [
n, t, sz, f,
args.empty? ? "" : args.map { |a| "\t#{a}" }.join
])
end
file.write("\n") unless @functions.empty?
file.write("\n")
end

def write_instruments(file, timeline)
Expand Down
10 changes: 4 additions & 6 deletions spec/csound_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
end

it "should write a valid Csound score" do
File.should_receive(:open).and_yield(f = mock_file)
File.should_receive(:open).and_yield(f = MockFile.new)
@writer.write(@score)
f.buf.should == <<SCO
f 1 0 0 1 example.wav 0 0 0
Expand All @@ -28,10 +28,8 @@
SCO
end

def mock_file
Class.new {
def buf; @buf ||= "" end
def write(str) buf << str end
}.new
class MockFile
def buf; @buf ||= "" end
def write(str) buf << str end
end
end

0 comments on commit 69528b4

Please sign in to comment.