Class: Stave::Theory::Circle

Inherits:
Object
  • Object
show all
Defined in:
lib/stave/theory/circle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, root:) ⇒ Circle

Returns a new instance of Circle.



6
7
8
9
# File 'lib/stave/theory/circle.rb', line 6

def initialize(type:, root:)
  @type = type
  @root = root
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



4
5
6
# File 'lib/stave/theory/circle.rb', line 4

def root
  @root
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/stave/theory/circle.rb', line 4

def type
  @type
end

Instance Method Details

#key_signaturesObject



17
18
19
# File 'lib/stave/theory/circle.rb', line 17

def key_signatures
  notes.map { |root| Scale.major_from(root).key_signature }
end

#notesObject



11
12
13
14
15
# File 'lib/stave/theory/circle.rb', line 11

def notes
  7.times.inject([root]) do |notes, _|
    notes + [notes.last + type.step]
  end
end