Sha256: 36a7a35cdd031ab12d3220eccde5a30bb1818bc3239876ab2ec22d013d6ef0ff
Contents?: true
Size: 935 Bytes
Versions: 2
Compression:
Stored size: 935 Bytes
Contents
module Music module Transcription class Meter include Validatable attr_reader :measure_duration, :beat_duration, :beats_per_measure def initialize beats_per_measure, beat_duration @beats_per_measure = beats_per_measure @beat_duration = beat_duration @measure_duration = beats_per_measure * beat_duration @check_methods = [ :check_beats_per_measure, :check_beat_duration ] end def check_beats_per_measure unless @beats_per_measure.is_a?(Integer) && @beats_per_measure > 0 raise NotPositiveIntegerError, "beats per measure #{@beats_per_measure} is not a positive integer" end end def check_beat_duration unless @beat_duration > 0 raise ValueNotPositiveError, "beat duration #{@beat_duration} is not positive" 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.7.3 | lib/music-transcription/meter.rb |
music-transcription-0.7.2 | lib/music-transcription/meter.rb |