Class: Sergovia::Scorers::Stretch
- Inherits:
-
Object
- Object
- Sergovia::Scorers::Stretch
- Defined in:
- lib/sergovia/scorers/stretch.rb
Instance Attribute Summary collapse
-
#fingering ⇒ Object
readonly
Returns the value of attribute fingering.
Instance Method Summary collapse
-
#initialize(fingering) ⇒ Stretch
constructor
A new instance of Stretch.
- #score ⇒ Object
Constructor Details
#initialize(fingering) ⇒ Stretch
Returns a new instance of Stretch.
7 8 9 |
# File 'lib/sergovia/scorers/stretch.rb', line 7 def initialize(fingering) @fingering = fingering end |
Instance Attribute Details
#fingering ⇒ Object (readonly)
Returns the value of attribute fingering.
5 6 7 |
# File 'lib/sergovia/scorers/stretch.rb', line 5 def fingering @fingering end |
Instance Method Details
#score ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sergovia/scorers/stretch.rb', line 11 def score #handle nils frets = fingering.notes.map(&:fret).reject { |n| n == 0 }.sort if frets.count > 1 span = (frets.max - frets.min) if span > 6 return 0.00 elsif span == 6 return 0.10 elsif span == 5 return 0.25 elsif span == 4 return 0.75 else return 1.00 end else return 1.00 end end |