Class: Tonal::ReducedRatio
Constant Summary collapse
- IDENTITY_RATIO =
1
Constants inherited from Ratio
Instance Attribute Summary
Attributes inherited from Ratio
#antecedent, #consequent, #equave, #label, #reduced_antecedent, #reduced_consequent
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(antecedent, consequent = 1, label: nil, equave: 2) ⇒ Tonal::ReducedRatio constructor
-
#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, #interval_with, #invert, #lcm, #log_weil_height, #max_prime, #max_prime_within?, #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?
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
#invert! ⇒ Tonal::ReducedRatio
Returns with antecedent and precedent switched.
32 33 34 35 36 |
# File 'lib/tonal/reduced_ratio.rb', line 32 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 |