Class: Lydown::Rendering::Duration

Inherits:
Base
  • Object
show all
Defined in:
lib/lydown/rendering/music.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#find_prev_event, #initialize, #next_event, #prev_event

Constructor Details

This class inherits a constructor from Lydown::Rendering::Base

Class Method Details

.full_bar_value(time) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/lydown/rendering/music.rb', line 15

def self.full_bar_value(time)
  r = Rational(time)
  case r.numerator
  when 1
    r.denominator.to_s
  when 3
    case r.denominator
    when 1
      "\\breve."
    else
      "#{r.denominator / 2}."
    end
  else
    nil
  end
end

Instance Method Details

#translateObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/lydown/rendering/music.rb', line 32

def translate
  Notes.cleanup_duration_macro(@context)

  # close tuplet braces
  if @context['process/tuplet_mode']
    TupletDuration.emit_tuplet_end(@context)
    @context['process/tuplet_mode'] = nil
  end

  if @context['process/grace_mode']
    Grace.emit_grace_end(@context)
    @context['process/grace_mode'] = nil
  end

  value = @event[:value].sub(/^[0-9]+|l/) {|m| LILYPOND_DURATIONS[m] || m}

  if next_event && next_event[:type] == :stand_alone_figures
    @context['process/figures_duration_value'] = value
  else
    @context['process/duration_values'] = [value]
    @context['process/cross_bar_dotting'] = @event[:cross_bar_dotting]
    @context['process/tuplet_mode'] = nil
    @context['process/duration_macro'] = nil unless @context['process/macro_group']
  end
end