Module: Scruby::Audio::Ugens::UgenOperations

Included in:
Ugen
Defined in:
lib/scruby/audio/ugens/ugen_operations.rb

Defined Under Namespace

Modules: BinaryOperations, UnaryOperators

Constant Summary collapse

UNARY =
operation_indices['unary']
BINARY =
operation_indices['binary']
OP_SYMBOLS =
{ :+ => :plus, :- => :minus, :* => :mult, :/ => :div2, :<= => :less_than_or_eql, :>= => :more_than_or_eql }

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/scruby/audio/ugens/ugen_operations.rb', line 14

def self.included( klass )
  klass.send( :include, BinaryOperations )
  begin; klass.send( :include, UnaryOperators ) if klass.new.ugen?; rescue; end

  BINARY.each_key do |operator|
    override = OP_SYMBOLS[operator] || operator #can't name a method ugen_+ so use OP_SYMBOLS hash to get a 'safe' name
    begin; klass.send :alias_method, "original_#{override}", operator; rescue; end #if there is an original operator method make an alias with the prefix 'original' so it may be called latter
    klass.send :alias_method, operator, "ugen_#{override}" #alias the newly added operator method with the name of the operator( +, -, mod, etc...)
  end
end

Instance Method Details

#valid_ugen_input?Boolean

Returns:



10
11
12
# File 'lib/scruby/audio/ugens/ugen_operations.rb', line 10

def valid_ugen_input?
  true
end