Class: HeadMusic::Style::Analysis
- Inherits:
-
Object
- Object
- HeadMusic::Style::Analysis
- Defined in:
- lib/head_music/style/analysis.rb
Overview
An analysis of music according to a style guide.
Instance Attribute Summary collapse
-
#guide ⇒ Object
readonly
Returns the value of attribute guide.
-
#voice ⇒ Object
readonly
Returns the value of attribute voice.
Instance Method Summary collapse
- #adherent? ⇒ Boolean
- #annotations ⇒ Object
- #fitness ⇒ Object
-
#initialize(guide, voice) ⇒ Analysis
constructor
A new instance of Analysis.
- #messages ⇒ Object (also: #annotation_messages)
Constructor Details
#initialize(guide, voice) ⇒ Analysis
Returns a new instance of Analysis.
10 11 12 13 |
# File 'lib/head_music/style/analysis.rb', line 10 def initialize(guide, voice) @guide = guide @voice = voice end |
Instance Attribute Details
#guide ⇒ Object (readonly)
Returns the value of attribute guide.
8 9 10 |
# File 'lib/head_music/style/analysis.rb', line 8 def guide @guide end |
#voice ⇒ Object (readonly)
Returns the value of attribute voice.
8 9 10 |
# File 'lib/head_music/style/analysis.rb', line 8 def voice @voice end |
Instance Method Details
#adherent? ⇒ Boolean
30 31 32 |
# File 'lib/head_music/style/analysis.rb', line 30 def adherent? fitness == 1 end |
#annotations ⇒ Object
20 21 22 |
# File 'lib/head_music/style/analysis.rb', line 20 def annotations @annotations ||= @guide.analyze(voice) end |
#fitness ⇒ Object
24 25 26 27 28 |
# File 'lib/head_music/style/analysis.rb', line 24 def fitness return 1.0 if annotations.empty? @fitness ||= fitness_scores.inject(:+).to_f / fitness_scores.length end |
#messages ⇒ Object Also known as: annotation_messages
15 16 17 |
# File 'lib/head_music/style/analysis.rb', line 15 def annotations.reject(&:adherent?).map(&:message) end |