Class: Clef::Layout::Stem

Inherits:
Object
  • Object
show all
Defined in:
lib/clef/layout/stem.rb

Class Method Summary collapse

Class Method Details

.direction(note_or_notes, clef) ⇒ Symbol

Parameters:

Returns:

  • (Symbol)


10
11
12
13
14
15
# File 'lib/clef/layout/stem.rb', line 10

def direction(note_or_notes, clef)
  notes = Array(note_or_notes)
  middle = diatonic_step(clef.reference_pitch)
  down_votes = notes.count { |note| diatonic_step(note.pitch) > middle }
  (down_votes > (notes.length / 2.0)) ? :down : :up
end

.length(note, _clef, _direction) ⇒ Float

Parameters:

Returns:

  • (Float)


21
22
23
24
# File 'lib/clef/layout/stem.rb', line 21

def length(note, _clef, _direction)
  extra = ledger_extension(note.pitch)
  Clef::Engraving::Rules::STEM_LENGTH + extra
end