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.
685 686 687 688 689 690 691 692 693 694 695 696 697 |
# File 'lib/musa-dsl/neumalang/neumalang.rb', line 685 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 |