Class: Stretto::Tokens::HarmonyWithMelodyToken
Overview
Token result from parsing a harmony
Instance Method Summary collapse
-
#music_elements ⇒ Array(MusicElements::MusicElement)
AN array of the music elements that form the harmony.
-
#to_stretto(pattern = nil) ⇒ MusicElements::Harmony, MusicElements::Melody
Returns the constructed Harmony or Melody object.
Methods inherited from HashToken
Instance Method Details
#music_elements ⇒ Array(MusicElements::MusicElement)
Returns AN array of the music elements that form the harmony.
27 28 29 |
# File 'lib/stretto/grammar/tokens/harmony_with_melody_token.rb', line 27 def music_elements @music_elements ||= harmony_elements(@pattern) end |
#to_stretto(pattern = nil) ⇒ MusicElements::Harmony, MusicElements::Melody
Returns the constructed Harmony or Melody object. It is a Harmony when there is more than one element (e.g. “A+B_C”)
16 17 18 19 20 21 22 23 24 |
# File 'lib/stretto/grammar/tokens/harmony_with_melody_token.rb', line 16 def to_stretto(pattern = nil) @pattern = pattern music_elements = harmony_elements(pattern) if music_elements.size == 1 and music_elements.first.kind_of?(Stretto::MusicElements::Melody) music_elements.first else Stretto::MusicElements::Harmony.new(self, pattern) end end |