Class: Lydown::Rendering::DurationMacro

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

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

Instance Method Details

#translateObject



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/lydown/rendering/music.rb', line 260

def translate
  Notes.cleanup_duration_macro(@context)
  
  if @event[:macro] =~ /^[a-zA-Z_]/
    macro = @context.get_current_setting('macros')[@event[:macro]]
    if macro
      if macro =~ /^\{(.+)\}$/
        macro = $1
      end
      # replace the repeating note placeholder with another sign in order to
      # avoid mixing up with repeating notes from outside the macro
      @context['process/duration_macro'] = macro.gsub('@', '')
    else
      raise LydownError, "Unknown macro #{@event[:macro]}"
    end
  else
    @context['process/duration_macro'] = @event[:macro]
  end
end