Class: Clef::Notation::Beam
- Inherits:
-
Object
- Object
- Clef::Notation::Beam
- Defined in:
- lib/clef/notation/beam.rb
Instance Attribute Summary collapse
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
Instance Method Summary collapse
-
#initialize(notes) ⇒ Beam
constructor
A new instance of Beam.
- #level ⇒ Integer
Constructor Details
#initialize(notes) ⇒ Beam
Returns a new instance of Beam.
9 10 11 12 13 |
# File 'lib/clef/notation/beam.rb', line 9 def initialize(notes) raise ArgumentError, "beam requires at least two notes" if notes.length < 2 @notes = notes end |
Instance Attribute Details
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
6 7 8 |
# File 'lib/clef/notation/beam.rb', line 6 def notes @notes end |
Instance Method Details
#level ⇒ Integer
16 17 18 19 20 21 22 |
# File 'lib/clef/notation/beam.rb', line 16 def level shortest = notes.map { |note| note.duration.base_value }.min return 1 if shortest >= Rational(1, 8) return 2 if shortest >= Rational(1, 16) 3 end |