rb-music 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rb-music/note.rb +1 -1
- data/lib/rb-music/note_set.rb +5 -0
- data/lib/rb-music/version.rb +1 -1
- data/spec/rb-music/note_set_spec.rb +34 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ede716588e8782f57b070342bc97120fe484cd5f
|
4
|
+
data.tar.gz: 7679fb3d8e55ab2789b83197933c9ecb267445f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcbb0c626c7e84a5ccf0b9f2b315fd730914f977c9a66785addb020bd95c0433ecf7de5c9a92d8e179d8a2f815aaff84a16e5964593519328621803a29f7548f
|
7
|
+
data.tar.gz: 5c11ae0a331f398dfaa0f14c053179039fd80913224a0a9b2482627c31eec8977bf22f2b2028af04678f7d1ed3fd4eae788fdab7623c35eaf3414fa2fb3de2ef
|
data/lib/rb-music/note.rb
CHANGED
data/lib/rb-music/note_set.rb
CHANGED
@@ -38,6 +38,7 @@ module RBMusic
|
|
38
38
|
def <<(other)
|
39
39
|
@notes << other
|
40
40
|
end
|
41
|
+
alias_method :push, :<<
|
41
42
|
|
42
43
|
def map(&block)
|
43
44
|
@notes.map(&block)
|
@@ -48,6 +49,10 @@ module RBMusic
|
|
48
49
|
end
|
49
50
|
alias_method :eql?, :==
|
50
51
|
|
52
|
+
def size
|
53
|
+
@notes.size
|
54
|
+
end
|
55
|
+
|
51
56
|
def add(that)
|
52
57
|
NoteSet.new(@notes.map { |note| note.add(that) })
|
53
58
|
end
|
data/lib/rb-music/version.rb
CHANGED
@@ -100,6 +100,40 @@ describe RBMusic::NoteSet do
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
+
describe "#each" do
|
104
|
+
let(:notes) { [double(foo: true), double(foo: true)] }
|
105
|
+
let(:subject) { described_class.new(notes) }
|
106
|
+
|
107
|
+
it "delegates to the notes array" do
|
108
|
+
notes[0].should_receive(:foo)
|
109
|
+
notes[1].should_receive(:foo)
|
110
|
+
|
111
|
+
subject.each do |note|
|
112
|
+
note.foo
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "#<<" do
|
118
|
+
let(:notes) { ["foo", "bar"] }
|
119
|
+
let(:note) { "baz" }
|
120
|
+
let(:subject) { described_class.new(notes) }
|
121
|
+
|
122
|
+
it "adds to the notes array" do
|
123
|
+
subject << note
|
124
|
+
|
125
|
+
subject.notes.should == ["foo", "bar", "baz"]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "#size" do
|
130
|
+
let(:notes) { ["foo", "bar"] }
|
131
|
+
|
132
|
+
it "is the amount of notes in the set" do
|
133
|
+
described_class.new(notes).size.should == 2
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
103
137
|
describe "#add" do
|
104
138
|
let(:f4) { Note.from_latin("F4") }
|
105
139
|
let(:g4) { Note.from_latin("G4") }
|