Class: Musicality::ScaleClass
- Inherits:
-
Object
- Object
- Musicality::ScaleClass
- Includes:
- Enumerable
- Defined in:
- lib/musicality/composition/model/scale_class.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #each ⇒ Object
-
#initialize(intervals) ⇒ ScaleClass
constructor
A new instance of ScaleClass.
- #intervals ⇒ Object
- #rotate(n = 1) ⇒ Object
- #to_pitch_seq(start_pitch) ⇒ Object
- #to_scale(pitch_class) ⇒ Object
Methods included from Enumerable
Constructor Details
#initialize(intervals) ⇒ ScaleClass
Returns a new instance of ScaleClass.
6 7 8 9 10 11 |
# File 'lib/musicality/composition/model/scale_class.rb', line 6 def initialize intervals if intervals.detect {|x| x <= 0 } raise NonPositiveError, "One or more scale intervals (#{intervals}) is non-positive" end @intervals = intervals end |
Instance Method Details
#==(other) ⇒ Object
15 16 17 |
# File 'lib/musicality/composition/model/scale_class.rb', line 15 def ==(other) self.entries == other.entries end |
#each ⇒ Object
19 20 21 22 |
# File 'lib/musicality/composition/model/scale_class.rb', line 19 def each return @intervals.each unless block_given? @intervals.each {|x| yield x } end |
#intervals ⇒ Object
13 |
# File 'lib/musicality/composition/model/scale_class.rb', line 13 def intervals; self.entries; end |
#rotate(n = 1) ⇒ Object
32 33 34 |
# File 'lib/musicality/composition/model/scale_class.rb', line 32 def rotate n = 1 ScaleClass.new(@intervals.rotate(n)) end |
#to_pitch_seq(start_pitch) ⇒ Object
24 25 26 |
# File 'lib/musicality/composition/model/scale_class.rb', line 24 def to_pitch_seq start_pitch AddingSequence.new(@intervals, start_pitch) end |