Class: Stretto::MusicElements::Measure

Inherits:
MusicElement show all
Defined in:
lib/stretto/music_elements/measure.rb

Overview

Does not have effect in the playback, it represents a measure for readability of the music texts

Instance Attribute Summary

Attributes inherited from MusicElement

#original_string, #pattern

Attributes included from Node

#next, #prev

Instance Method Summary (collapse)

Methods inherited from MusicElement

#build_music_string, #duration, #end_of_tie?, #start_of_tie?, #substitute_variables!, #to_s

Constructor Details

- (Measure) initialize(string_or_options, pattern = nil)



10
11
12
13
14
15
16
# File 'lib/stretto/music_elements/measure.rb', line 10

def initialize(string_or_options, pattern = nil)
  token = case string_or_options
    when String then Stretto::Parser.parse_measure!(string_or_options)
    else string_or_options
  end
  super(token[:text_value], pattern)
end

Instance Method Details

- (Object) tied_duration

TODO: Make tests for other elements inside ties, move this to MusicElement



31
32
33
# File 'lib/stretto/music_elements/measure.rb', line 31

def tied_duration
  tied_elements.inject(0){|sum, element| sum + element.duration}
end

- (Object) tied_elements

TODO: Make tests for other elements inside ties, move this to MusicElement



20
21
22
23
24
25
26
27
# File 'lib/stretto/music_elements/measure.rb', line 20

def tied_elements
  next_element = self.next
  if next_element
    next_element.tied_elements
  else
    []
  end
end