Sha256: 9f10314eb43c6feac73840aa44b417ae3b2f8d79e8f8b174203802e844d97d27
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
module Music module Transcription class Meter include Validatable attr_reader :measure_duration, :beat_duration, :beats_per_measure @@check_methods = [ :check_beats_per_measure, :check_beat_duration ] def initialize beats_per_measure, beat_duration @beats_per_measure = beats_per_measure @beat_duration = beat_duration @measure_duration = beats_per_measure * beat_duration end def check_beats_per_measure unless @beats_per_measure > 0 raise NonPositiveError, "beats per measure #{@beats_per_measure} is not positive" end unless @beats_per_measure.is_a?(Integer) raise NonIntegerError, "beats per measure #{@beats_per_measure} is not an integer" end end def check_beat_duration unless @beat_duration > 0 raise NonPositiveError, "beat duration #{@beat_duration} is not positive" end unless @beat_duration > 0 raise NonRationalError, "beat duration #{@beat_duration} is a rational" end end def ==(other) return (@beats_per_measure == other.beats_per_measure && @beat_duration == other.beat_duration) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
music-transcription-0.11.0 | lib/music-transcription/model/meter.rb |
music-transcription-0.10.0 | lib/music-transcription/meter.rb |