Class: HeadMusic::Rudiment::Pitch::HelmholtzNotation

Inherits:
Object
  • Object
show all
Defined in:
lib/head_music/rudiment/pitch/helmholtz_notation.rb

Overview

Helmholtz pitch notation, in which the register is spelled by the case of the letter and the marks after it: C,, C, C c c’ c’’.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spelling, register) ⇒ HelmholtzNotation

Returns a new instance of HelmholtzNotation.



7
8
9
10
# File 'lib/head_music/rudiment/pitch/helmholtz_notation.rb', line 7

def initialize(spelling, register)
  @spelling = spelling
  @register = HeadMusic::Rudiment::Register.get(register)
end

Instance Attribute Details

#registerObject (readonly)

Returns the value of attribute register.



5
6
7
# File 'lib/head_music/rudiment/pitch/helmholtz_notation.rb', line 5

def register
  @register
end

#spellingObject (readonly)

Returns the value of attribute spelling.



5
6
7
# File 'lib/head_music/rudiment/pitch/helmholtz_notation.rb', line 5

def spelling
  @spelling
end

Instance Method Details

#cased_spellingObject (private)



18
19
20
21
22
# File 'lib/head_music/rudiment/pitch/helmholtz_notation.rb', line 18

def cased_spelling
  return spelling.to_s.downcase if register.helmholtz_case == :lower

  spelling.to_s
end

#to_sObject



12
13
14
# File 'lib/head_music/rudiment/pitch/helmholtz_notation.rb', line 12

def to_s
  cased_spelling + register.helmholtz_marks
end