diff --git a/lib/music.rb b/lib/music.rb index e4ceec0..15e09e8 100644 --- a/lib/music.rb +++ b/lib/music.rb @@ -109,12 +109,12 @@ def none; rest(0) end =end # Compose a list of arrangements sequentially. - def line(*ms) + def seq(*ms) ms.inject { |a, b| a & b } end # Compose a list of arrangements in parallel. - def chord(*ms) + def par(*ms) ms.inject { |a, b| a | b } end end diff --git a/lib/music/score.rb b/lib/music/score.rb index b92d0f5..8282fa0 100644 --- a/lib/music/score.rb +++ b/lib/music/score.rb @@ -30,16 +30,14 @@ def self.none; rest(0) end def none; self.class.none end # Sequential composition. - def seq(other) + def &(other) Seq.new(self, other) end - alias & seq # Parallel (concurrent) composition. - def par(other) + def |(other) Par.new(self, other) end - alias | par # Parallel composition. The duration of the longer sequence is truncated # to match the duration of the shorter one. diff --git a/spec/score_spec.rb b/spec/score_spec.rb index 76a070b..3cbe5ae 100644 --- a/spec/score_spec.rb +++ b/spec/score_spec.rb @@ -3,14 +3,12 @@ shared_examples_for "all arrangements" do it "can be composed sequentially" do seq = Seq.new(@object, rest(0)) - ( @object & rest(0) ).should == seq - @object.seq( rest(0) ).should == seq + (@object & rest(0)).should == seq end it "can be composed in parallel" do par = Par.new(@object, rest(0)) - ( @object | rest(0) ).should == par - @object.par( rest(0) ).should == par + (@object | rest(0)).should == par end it "preserves its structure when mapped with the identity function" do @@ -83,8 +81,8 @@ end it "can be compared" do - @left.seq(@right).should == @object - @right.seq(@left).should_not == @object + (@left & @right).should == @object + (@right & @left).should_not == @object end it "can be transposed" do @@ -117,8 +115,8 @@ end it "can be compared" do - @top.par(@bottom).should == @object - @bottom.par(@top).should_not == @object + (@top | @bottom).should == @object + (@bottom | @top).should_not == @object end it "can be transposed" do @@ -264,11 +262,11 @@ end it "should compose lists of arrangements sequentially" do - line(note(60), note(64), note(67)).should == note(60) & note(64) & note(67) + seq(note(60), note(64), note(67)).should == note(60) & note(64) & note(67) end it "should compose lists of arrangements in parallel" do - chord(note(60), note(64), note(67)).should == note(60) | note(64) | note(67) + par(note(60), note(64), note(67)).should == note(60) | note(64) | note(67) end end