Class: Api

Inherits:
Object show all
Defined in:
lib/api/api.rb

Overview

base class for most of the things the user will touch directly

Direct Known Subclasses

Dist, HitSq, Mapper, Snd

Instance Method Summary collapse

Constructor Details

#initializeApi

Returns a new instance of Api.



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

def initialize
  @parents=[]
end

Instance Method Details

#<<(toadd) ⇒ Object

Add things to me. This can be applied for many classes. Can handles arrays of excepted types. object Dist can add Dist to children. object Dist can add Snd to list of sounds. object Dist and HitSq can add HitSq to list of hits. object Dist and HitSq can add Numbers to list of hits. object Snd can repalce ToneSeq. object Snd can add Snd to repalce its ToneSeq. object Snd can add TonePart to add it to its ToneSeq.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/api/api.rb', line 14

def << toadd
#    puts "type: #{toadd.class}"
  case toadd
  when Array
#      puts "recognised array"
    toadd.each do |ta| 
      r = add_single ta
      raise "This type is not recongnised." if r ==false
    end
  else
    r=add_single toadd
    raise "This type is not recongnised." if r==false
  end
  self
end

#>>(todel) ⇒ Object

Delete things from me



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/api/api.rb', line 30

def >> todel
#    puts "type: #{todel.class}"
  case todel
  when Array
#      puts "deleting array #{todel}"
    todel.each do |ta| 
      r = del_single ta
      raise "This type is not recongnised." if r ==false
    end
  else
    r=del_single todel
    raise "This type is not recongnised." if r==false
  end
  self
end

#parent(index = 0) ⇒ Object



46
47
48
# File 'lib/api/api.rb', line 46

def parent index=0
  @parents[index]
end