Sha256: cf90c5cff142488ab0c1ddfb64b36b9b3443bcbe3eceb3286e37a2185cad0502
Contents?: true
Size: 739 Bytes
Versions: 18
Compression:
Stored size: 739 Bytes
Contents
# frozen_string_literal: true # A module for style analysis and guidelines. module HeadMusic::Style; end # An analysis of music according to a style guide. class HeadMusic::Style::Analysis attr_reader :guide, :voice def initialize(guide, voice) @guide = guide @voice = voice end def messages annotations.reject(&:adherent?).map(&:message) end alias annotation_messages messages def annotations @annotations ||= @guide.analyze(voice) end def fitness return 1.0 if annotations.empty? @fitness ||= fitness_scores.inject(:+).to_f / fitness_scores.length end def adherent? fitness == 1 end private def fitness_scores @fitness_scores ||= annotations.map(&:fitness) end end
Version data entries
18 entries across 18 versions & 1 rubygems