Class: Scruby::Synth

Inherits:
Node show all
Defined in:
lib/scruby/synth.rb

Constant Summary

Constants inherited from Node

Node::ACTIONS

Instance Attribute Summary collapse

Attributes inherited from Node

#group, #id, #servers

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#free, #map, #move_after, #move_before, #playing?, reset!, #run, #send, #send_bundle, #set, #trace

Constructor Details

#initialize(name, servers) ⇒ Synth

Returns a new instance of Synth.



5
6
7
8
# File 'lib/scruby/synth.rb', line 5

def initialize name, servers
  super servers
  @name = name.to_s
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/scruby/synth.rb', line 3

def name
  @name
end

Class Method Details

.after(target, name, args = {}) ⇒ Object



28
29
30
# File 'lib/scruby/synth.rb', line 28

def after target, name, args = {}
  new name, args, target, :after
end

.before(target, name, args = {}) ⇒ Object



32
33
34
# File 'lib/scruby/synth.rb', line 32

def before target, name, args = {}
  new name, args, target, :before
end

.head(target, name, args = {}) ⇒ Object



36
37
38
# File 'lib/scruby/synth.rb', line 36

def head target, name, args = {}
  new name, args, target, :head
end

.new(name, args = {}, target = nil, action = :head) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/scruby/synth.rb', line 11

def new name, args = {}, target = nil, action = :head
  case target
  when nil
    target_id, servers = 1, nil
  when Group
    target_id, servers = group.id, target.servers
  when Node
    target_id, servers = 1, target.servers
  else
    raise TypeError.new("expected #{ target } to kind of Node or nil")
  end

  synth = super name, servers
  synth.send '/s_new', synth.name, synth.id, Node::ACTIONS.index(action), target_id, args
  synth
end

.replace(target, name, args = {}) ⇒ Object



44
45
46
# File 'lib/scruby/synth.rb', line 44

def replace target, name, args = {}
  new name, args, target, :replace
end

.tail(target, name, args = {}) ⇒ Object



40
41
42
# File 'lib/scruby/synth.rb', line 40

def tail target, name, args = {}
  new name, args, target, :tail
end