Class: Stretto::Tokens::DurationToken

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/stretto/grammar/tokens/duration_token.rb

Overview

Token result from parsing a duration

Examples:

"wh", "q*3:4", "/2.5"

Instance Method Summary collapse

Instance Method Details

#dotsString

Returns a string with the number of dots in the duration

Examples:

2 (for string Cmajh..



41
42
43
# File 'lib/stretto/grammar/tokens/duration_token.rb', line 41

def dots
  duration_string.dots
end

#duration_characterString

Returns The duration expressed as characters

Examples:

"h", "wq"



30
31
32
# File 'lib/stretto/grammar/tokens/duration_token.rb', line 30

def duration_character
  duration_string.duration_character
end

#end_of_tie?true, false



15
16
17
# File 'lib/stretto/grammar/tokens/duration_token.rb', line 15

def end_of_tie?
  _end_of_tie.text_value.present? if _end_of_tie
end

#start_of_tie?true, false



10
11
12
# File 'lib/stretto/grammar/tokens/duration_token.rb', line 10

def start_of_tie?
  _start_of_tie.text_value.present? if _start_of_tie
end

#tupletHash?

Returns A hash containing both the numerator and denominator, if present

Examples:

{ :numerator => 2, :denominator => 3 }



21
22
23
24
25
26
# File 'lib/stretto/grammar/tokens/duration_token.rb', line 21

def tuplet
  if duration_string.tuplet
    {:numerator   => duration_string.tuplet.numerator,
     :denominator => duration_string.tuplet.denominator}
  end
end

#valueValue?



35
36
37
# File 'lib/stretto/grammar/tokens/duration_token.rb', line 35

def value
  Stretto::Value.new(duration_string.value.wrap) if duration_string.value
end