class Musicality::Meter
Constants
- CONVERSION_METHOD
- PARSER
Attributes
beat_duration[R]
beats_per_measure[R]
measure_duration[R]
Public Class Methods
new(beats_per_measure, beat_duration)
click to toggle source
# File lib/musicality/notation/model/meter.rb, line 12 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
Public Instance Methods
==(other)
click to toggle source
# File lib/musicality/notation/model/meter.rb, line 42 def ==(other) return (@beats_per_measure == other.beats_per_measure && @beat_duration == other.beat_duration) end
check_beat_duration()
click to toggle source
# File lib/musicality/notation/model/meter.rb, line 32 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
check_beats_per_measure()
click to toggle source
# File lib/musicality/notation/model/meter.rb, line 22 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
check_methods()
click to toggle source
# File lib/musicality/notation/model/meter.rb, line 18 def check_methods [ :check_beats_per_measure, :check_beat_duration ] end
to_lilypond()
click to toggle source
# File lib/musicality/printing/lilypond/meter_engraving.rb, line 4 def to_lilypond num = beats_per_measure * beat_duration.numerator den = beat_duration.denominator "\\time #{num}/#{den}" end
to_s()
click to toggle source
# File lib/musicality/notation/model/meter.rb, line 47 def to_s if beat_duration.numerator == 1 num = beats_per_measure * beat_duration.numerator den = beat_duration.denominator "#{num}/#{den}" else "#{beats_per_measure}*#{beat_duration}" end end