Class: Juicy::ChordProgression
- Inherits:
-
Object
- Object
- Juicy::ChordProgression
- Defined in:
- lib/juicy/chord_progression.rb
Instance Attribute Summary collapse
-
#chords ⇒ Object
Returns the value of attribute chords.
Instance Method Summary collapse
- #initial_play_time ⇒ Object
-
#initialize(key, mode, numerals = [1,4,1,5]) ⇒ ChordProgression
constructor
A new instance of ChordProgression.
- #inspect ⇒ Object
- #play ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(key, mode, numerals = [1,4,1,5]) ⇒ ChordProgression
Returns a new instance of ChordProgression.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/juicy/chord_progression.rb', line 7 def initialize(key, mode, numerals = [1,4,1,5]) @numerals = numerals #given a key and a mode, a number can tell me what chord. @chords = [ Chord.new(root: "A", quality: :major), Chord.new(root: "D", quality: :major), Chord.new(root: "A", quality: :major), Chord.new(root: "E", quality: :major) ] #@numerals.each do |numeral| # @chords << Chord.new(numeral) #end end |
Instance Attribute Details
#chords ⇒ Object
Returns the value of attribute chords.
5 6 7 |
# File 'lib/juicy/chord_progression.rb', line 5 def chords @chords end |
Instance Method Details
#initial_play_time ⇒ Object
46 47 48 |
# File 'lib/juicy/chord_progression.rb', line 46 def initial_play_time 0 end |
#inspect ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/juicy/chord_progression.rb', line 25 def inspect output = "" @chords.each do |chord| output += chord.inspect + ", " end output[0..-3] end |
#play ⇒ Object
50 51 52 53 54 |
# File 'lib/juicy/chord_progression.rb', line 50 def play @chords.each do |chord| 4.times {chord.play} end end |
#to_a ⇒ Object
41 42 43 44 |
# File 'lib/juicy/chord_progression.rb', line 41 def to_a [Chord.new(root: "C")] @chords end |
#to_s ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/juicy/chord_progression.rb', line 33 def to_s output = "" @progression.each do |scale_degree| output += scale_degree.to_s + ", " end output[0..-3] end |