Class: Tonal::ReducedRatio
Constant Summary collapse
- IDENTITY_RATIO =
1
Instance Attribute Summary
Attributes inherited from Ratio
#antecedent, #consequent, #equave, #reduced_antecedent, #reduced_consequent
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(antecedent, consequent = 1, label: nil, equave: 2) ⇒ Tonal::ReducedRatio constructor
-
#interval_with(ratio) ⇒ Tonal::Interval
Between ratio (upper) and self (lower).
-
#invert! ⇒ Tonal::ReducedRatio
With antecedent and precedent switched.
-
#to_basic_ratio ⇒ Tonal::Ratio
Self as an instance of unreduced ratio.
Methods inherited from Ratio
#*, #**, #+, #-, #/, #<=>, #approximate, #benedetti_height, #cent_diff, #combination, #difference, #div_times, ed, #efficiency, #equave_reduce, #equave_reduce!, #fraction_reduce, #inspect, #invert, #label, #lcm, #log_weil_height, #max_prime, #mediant_sum, #min_prime, #mirror, #negative, #period_degrees, #period_radians, #planar_degrees, #planar_radians, #plus_minus, #prime_divisions, #prime_vector, random_ratio, #ratio, #scale, #shear, #step, superparticular, superpartient, #tenney_height, #to_a, #to_cents, #to_f, #to_log, #to_log2, #to_r, #to_reduced_ratio, #to_v, #translate, #weil_height, #wilson_height, within_cents?, #within_prime?
Constructor Details
#initialize(antecedent, consequent = 1, label: nil, equave: 2) ⇒ Tonal::ReducedRatio
11 12 13 14 |
# File 'lib/tonal/reduced_ratio.rb', line 11 def initialize(antecedent, consequent=1, label: nil, equave: 2/1r) super(antecedent, consequent, label: label, equave: equave) @antecedent, @consequent = @reduced_antecedent, @reduced_consequent end |
Class Method Details
.identity ⇒ Object
16 17 18 |
# File 'lib/tonal/reduced_ratio.rb', line 16 def self.identity self.new(IDENTITY_RATIO) end |
Instance Method Details
#interval_with(ratio) ⇒ Tonal::Interval
Returns between ratio (upper) and self (lower).
34 35 36 37 |
# File 'lib/tonal/reduced_ratio.rb', line 34 def interval_with(ratio) r = ratio.is_a?(self.class) ? ratio : self.class.new(ratio) Tonal::Interval.new(r, self) end |
#invert! ⇒ Tonal::ReducedRatio
Returns with antecedent and precedent switched.
43 44 45 46 47 |
# File 'lib/tonal/reduced_ratio.rb', line 43 def invert! super @antecedent, @consequent = @reduced_antecedent, @reduced_consequent self end |
#to_basic_ratio ⇒ Tonal::Ratio
Returns self as an instance of unreduced ratio.
24 25 26 |
# File 'lib/tonal/reduced_ratio.rb', line 24 def to_basic_ratio Tonal::Ratio.new(antecedent, consequent) end |