Class: Stretto::MusicElements::Tempo
- Inherits:
-
MusicElement
- Object
- MusicElement
- Stretto::MusicElements::Tempo
- Defined in:
- lib/stretto/music_elements/tempo.rb
Overview
Tempo represents the bpm of the song.
It is indicated by a T
followed by the value of the tempo. There are some predefined variables that define the most common tempos (see Variables::TEMPO_VARIABLES), and the default is allegro, that is, a tempo of T120
bpm
Instance Attribute Summary
Attributes inherited from MusicElement
Attributes included from Node
Instance Method Summary collapse
- #bpm ⇒ Object
-
#initialize(string_or_options, pattern = nil) ⇒ Tempo
constructor
A new instance of Tempo.
- #substitute_variables! ⇒ Object
- #value ⇒ Object
- #value=(value) ⇒ Object
Methods inherited from MusicElement
#build_music_string, #duration, #end_of_tie?, #start_of_tie?, #to_s
Constructor Details
#initialize(string_or_options, pattern = nil) ⇒ Tempo
Returns a new instance of Tempo.
14 15 16 17 18 19 20 21 |
# File 'lib/stretto/music_elements/tempo.rb', line 14 def initialize(, pattern = nil) token = case when String then Stretto::Parser.parse_tempo!() else end super(token[:text_value], pattern) @original_value = token[:value] end |
Instance Method Details
#bpm ⇒ Object
27 28 29 |
# File 'lib/stretto/music_elements/tempo.rb', line 27 def bpm value end |
#substitute_variables! ⇒ Object
35 36 37 |
# File 'lib/stretto/music_elements/tempo.rb', line 35 def substitute_variables! self.value = value end |
#value ⇒ Object
31 32 33 |
# File 'lib/stretto/music_elements/tempo.rb', line 31 def value @value || @original_value.to_i(@pattern) end |
#value=(value) ⇒ Object
23 24 25 |
# File 'lib/stretto/music_elements/tempo.rb', line 23 def value=(value) @value = value end |