lib/head_music/style/analysis.rb in head_music-0.11.9 vs lib/head_music/style/analysis.rb in head_music-0.13.2
- old
+ new
@@ -6,15 +6,26 @@
def initialize(ruleset, subject)
@ruleset = ruleset
@subject = subject
end
+ def messages
+ annotations.reject(&:perfect?).map(&:message)
+ end
+
def annotations
@annotations ||= @ruleset.analyze(subject)
end
def fitness
- annotations.map(&:fitness).reduce(1, :*)
+ return 1.0 if annotations.length == 0
+ fitness_scores.inject(:+).to_f / fitness_scores.length
+ end
+
+ private
+
+ def fitness_scores
+ annotations.map(&:fitness)
end
end
end
end