Skip to content

Commit

Permalink
Scissor::Chunk#loop is not destructive
Browse files Browse the repository at this point in the history
  • Loading branch information
youpy committed Dec 2, 2011
1 parent 1a5d84c commit 9c86ad8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/scissor/chunk.rb
Expand Up @@ -108,12 +108,14 @@ def +(other)


def loop(count) def loop(count)
orig_fragments = @fragments.clone orig_fragments = @fragments.clone
new_instance = Scissor()
new_instance.add_fragments(orig_fragments)


(count - 1).times do (count - 1).times do
add_fragments(orig_fragments) new_instance.add_fragments(orig_fragments)
end end


self new_instance
end end


alias * loop alias * loop
Expand Down
5 changes: 3 additions & 2 deletions spec/scissor_spec.rb
Expand Up @@ -88,8 +88,9 @@
end end


it "should loop" do it "should loop" do
scissor = @mp3.slice(0, 10).loop(3) scissor = @mp3.slice(0, 10)
scissor.duration.should eql(30.0) scissor.loop(3).duration.should eql(30.0)
scissor.duration.should eql(10.0)
end end


it "should loop using arithmetic operator" do it "should loop using arithmetic operator" do
Expand Down

0 comments on commit 9c86ad8

Please sign in to comment.