Module: Musa::Neumalang::Neumalang::Parser::DurationCalculation Private
- Included in:
- AbsDurationAttribute, DeltaDurationAttribute
- Defined in:
- lib/musa-dsl/neumalang/neumalang.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Helper module for duration calculations.
Calculates duration from notation including dots and slashes.
Supports: _2 (double), _/2 (half), _. (dotted), _.. (double dotted).
Instance Method Summary collapse
-
#duration ⇒ Rational
private
Calculates duration value.
Instance Method Details
#duration ⇒ Rational
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Calculates duration value.
704 705 706 707 708 709 710 711 712 713 714 715 716 |
# File 'lib/musa-dsl/neumalang/neumalang.rb', line 704 def duration base = capture(:number)&.value slashes = capture(:slashes)&.value || 0 base ||= Rational(1, 2**slashes.to_r) dots_extension = 0 capture(:mid_dots)&.value&.times do |i| dots_extension += Rational(base, 2**(i+1)) end base + dots_extension end |