Module: Stretto::Tokens::PatternToken

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

Overview

This is the token that parses a pattern, that is, a collection of music elements

Examples:

T I | C C D E | Rw. | Dmin”

Instance Method Summary collapse

Instance Method Details

#to_stretto(pattern = nil) ⇒ Array(MusicElements::MusicElement)

- TODO: This should return a Pattern object directly

Returns:



13
14
15
16
17
18
19
20
21
# File 'lib/stretto/grammar/tokens/pattern_token.rb', line 13

def to_stretto(pattern = nil)
  unless head.text_value.empty?
    [head.to_stretto(pattern)] + more_elements.elements.map do |element|
      element.music_element.to_stretto(pattern)
    end
  else
    []
  end
end