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

- (String) dots

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

- (String) duration_character

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

- (true, false) end_of_tie?



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

- (true, false) start_of_tie?



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

- (Hash?) tuplet

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

- (Value?) value



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