Class: Clef::Core::Tuplet
- Inherits:
-
Object
- Object
- Clef::Core::Tuplet
- Defined in:
- lib/clef/core/tuplet.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#normal ⇒ Object
readonly
Returns the value of attribute normal.
Instance Method Summary collapse
-
#initialize(actual, normal, elements) ⇒ Tuplet
constructor
A new instance of Tuplet.
- #length ⇒ Rational
- #ratio ⇒ Rational
Constructor Details
#initialize(actual, normal, elements) ⇒ Tuplet
Returns a new instance of Tuplet.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/clef/core/tuplet.rb', line 13 def initialize(actual, normal, elements) raise ArgumentError, "tuplet values must be positive" unless actual.is_a?(Integer) && actual.positive? && normal.is_a?(Integer) && normal.positive? @actual = actual @normal = normal @elements = Array(elements) validate_elements! @elements.freeze end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
8 9 10 |
# File 'lib/clef/core/tuplet.rb', line 8 def actual @actual end |
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
8 9 10 |
# File 'lib/clef/core/tuplet.rb', line 8 def elements @elements end |
#normal ⇒ Object (readonly)
Returns the value of attribute normal.
8 9 10 |
# File 'lib/clef/core/tuplet.rb', line 8 def normal @normal end |
Instance Method Details
#length ⇒ Rational
25 26 27 |
# File 'lib/clef/core/tuplet.rb', line 25 def length raw_length * ratio end |
#ratio ⇒ Rational
30 31 32 |
# File 'lib/clef/core/tuplet.rb', line 30 def ratio Rational(normal, actual) end |