Class: Stretto::MusicElements::Harmony
- Inherits:
-
MusicElement
- Object
- MusicElement
- Stretto::MusicElements::Harmony
- Defined in:
- lib/stretto/music_elements/harmony.rb
Overview
Represents a group of notes, chords and rests of different lengths that should play together.
It is similar to a HarmonicChord (see HarmonicChord with the difference that it can also include rests and melodies (see Melody)
Instance Attribute Summary collapse
-
#elements ⇒ Object
Returns the value of attribute elements.
Attributes inherited from MusicElement
Attributes included from Node
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize(string_or_options, pattern = nil) ⇒ Harmony
constructor
A new instance of Harmony.
- #pattern=(pattern) ⇒ Object
Methods inherited from MusicElement
#build_music_string, #end_of_tie?, #start_of_tie?, #substitute_variables!, #to_s
Constructor Details
#initialize(string_or_options, pattern = nil) ⇒ Harmony
Returns a new instance of Harmony.
15 16 17 18 19 20 21 22 |
# File 'lib/stretto/music_elements/harmony.rb', line 15 def initialize(, pattern = nil) token = case when String then Stretto::Parser.parse_harmony!() else end super(token[:text_value], pattern) @elements = token[:music_elements] end |
Instance Attribute Details
#elements ⇒ Object
Returns the value of attribute elements.
13 14 15 |
# File 'lib/stretto/music_elements/harmony.rb', line 13 def elements @elements end |
Instance Method Details
#duration ⇒ Object
25 26 27 |
# File 'lib/stretto/music_elements/harmony.rb', line 25 def duration @elements.map(&:duration).max end |
#pattern=(pattern) ⇒ Object
30 31 32 |
# File 'lib/stretto/music_elements/harmony.rb', line 30 def pattern=(pattern) @elements.each { |element| element.pattern = pattern } end |