Class: Mext::Numeric::Meter
- Inherits:
-
Object
- Object
- Mext::Numeric::Meter
- Defined in:
- lib/mext/numeric/meter.rb
Overview
Meter:
in music we cannot use the Rational class because the latter will make all due conversions simplifying meters (like: 4/4 => 1/1), which is not what we want
Instance Attribute Summary collapse
-
#divisor ⇒ Object
(also: #denominator)
Returns the value of attribute divisor.
-
#numerator ⇒ Object
Returns the value of attribute numerator.
Instance Method Summary collapse
-
#initialize(n, d) ⇒ Meter
constructor
A new instance of Meter.
- #to_r ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(n, d) ⇒ Meter
Returns a new instance of Meter.
17 18 19 20 |
# File 'lib/mext/numeric/meter.rb', line 17 def initialize(n, d) self.numerator = n.to_f self.divisor = d.to_f end |
Instance Attribute Details
#divisor ⇒ Object Also known as: denominator
Returns the value of attribute divisor.
13 14 15 |
# File 'lib/mext/numeric/meter.rb', line 13 def divisor @divisor end |
#numerator ⇒ Object
Returns the value of attribute numerator.
13 14 15 |
# File 'lib/mext/numeric/meter.rb', line 13 def numerator @numerator end |
Instance Method Details
#to_r ⇒ Object
22 23 24 |
# File 'lib/mext/numeric/meter.rb', line 22 def to_r Rational(self.numerator, self.divisor) end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/mext/numeric/meter.rb', line 26 def to_s "#{self.numerator}/#{self.divisor}" end |