Class: Juicy::ChordProgression

Inherits:
Object
  • Object
show all
Defined in:
lib/juicy/chord_progression.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChordProgression

Returns a new instance of ChordProgression.



7
8
9
10
11
12
13
# File 'lib/juicy/chord_progression.rb', line 7

def initialize
  @chords = []
  @chords << Chord.new(root: :C)
  @chords << Chord.new(root: :F, inversion: 2)
  @chords << Chord.new(root: :G, inversion: 1)
  @chords << Chord.new(root: :C)
end

Instance Attribute Details

#chordsObject

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_timeObject



36
37
38
# File 'lib/juicy/chord_progression.rb', line 36

def initial_play_time
  0
end

#inspectObject



15
16
17
18
19
20
21
# File 'lib/juicy/chord_progression.rb', line 15

def inspect
  output = ""
  @chords.each do |chord|
    output += chord.inspect + ", "
  end
  output[0..-3]
end

#playObject



40
41
42
43
44
# File 'lib/juicy/chord_progression.rb', line 40

def play
  @chords.each do |chord|
    4.times {chord.play}
  end
end

#to_aObject



31
32
33
34
# File 'lib/juicy/chord_progression.rb', line 31

def to_a
  [Chord.new(root: "C")]
  @chords
end

#to_sObject



23
24
25
26
27
28
29
# File 'lib/juicy/chord_progression.rb', line 23

def to_s
  output = ""
  @progression.each do |scale_degree|
    output += scale_degree.to_s + ", "
  end
  output[0..-3]
end