Module: Stretto::Tokens::NoteKeyAccidentalOctaveToken

Defined in:
lib/stretto/grammar/tokens/note_string_token.rb

Overview

Token result from parsing the part of a note that contains key, and optional accidental and octave values

Examples:

“C#7”

Instance Method Summary collapse

Instance Method Details

#accidentalString?

Returns The accidental of the note, if present (one of ‘bb’, ‘b’, ‘n’, ‘#’, ‘##’).

Examples:

“#”

Returns:

  • (String, nil)

    The accidental of the note, if present (one of ‘bb’, ‘b’, ‘n’, ‘#’, ‘##’)



56
57
58
# File 'lib/stretto/grammar/tokens/note_string_token.rb', line 56

def accidental
  note_key.accidental.text_value if note_key.accidental and note_key.accidental.text_value.present?
end

#keyString

Returns The key of the note (‘A’ through ‘G’).

Examples:

“C”

Returns:

  • (String)

    The key of the note (‘A’ through ‘G’)



50
51
52
# File 'lib/stretto/grammar/tokens/note_string_token.rb', line 50

def key
  note_key.key.text_value
end

#octaveString?

Returns The octave of the note, if present.

Examples:

“5”

Returns:

  • (String, nil)

    The octave of the note, if present



69
70
71
# File 'lib/stretto/grammar/tokens/note_string_token.rb', line 69

def octave
  _octave.text_value if _octave and _octave.text_value.present?
end

#pitchnil

Always return nil, as this is used to differentiate a note with a given pitch from one with key, octave and accidental whose pitch has to be calculated

Returns:

  • (nil)


63
64
65
# File 'lib/stretto/grammar/tokens/note_string_token.rb', line 63

def pitch
  nil
end