Sha256: 51bc8c148d6258aeae7ba25a4d1c98ac5788f43f5258aa11cf98343ee7643ddc

Contents?: true

Size: 616 Bytes

Versions: 7

Compression:

Stored size: 616 Bytes

Contents

module HeadMusic
  module Style
    class Analysis
      attr_reader :ruleset, :subject, :annotations

      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
        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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
head_music-0.14.8 lib/head_music/style/analysis.rb
head_music-0.14.7 lib/head_music/style/analysis.rb
head_music-0.14.5 lib/head_music/style/analysis.rb
head_music-0.14.4 lib/head_music/style/analysis.rb
head_music-0.14.2 lib/head_music/style/analysis.rb
head_music-0.14.1 lib/head_music/style/analysis.rb
head_music-0.13.2 lib/head_music/style/analysis.rb