Class: Livecode::ClockRecipients
- Inherits:
-
Object
- Object
- Livecode::ClockRecipients
show all
- Includes:
- Enumerable
- Defined in:
- lib/livecode/clock_recipients.rb
Overview
Recipients hash for the clock, see Clock for documentation.
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ClockRecipients.
8
9
10
|
# File 'lib/livecode/clock_recipients.rb', line 8
def initialize
@collection = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *args, &block) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/livecode/clock_recipients.rb', line 46
def method_missing(method_sym, *args, &block)
method_name = method_sym.to_s
if method_name =~ /=$/
self.set(method_name.gsub(/=$/, ''), *args)
elsif block_given?
self.set(method_name, *args, &block)
else
return nil unless self.has_key?(method_name)
self.get(method_name)
end
end
|
Instance Method Details
#each ⇒ Object
12
13
14
|
# File 'lib/livecode/clock_recipients.rb', line 12
def each
@collection.each{|key,r| yield r}
end
|
#each_with_index ⇒ Object
16
17
18
|
# File 'lib/livecode/clock_recipients.rb', line 16
def each_with_index
@collection.each{|key,r| yield key, r}
end
|
#enable_all ⇒ Object
Also known as:
play_all, unsolo
74
75
76
|
# File 'lib/livecode/clock_recipients.rb', line 74
def enable_all
each_with_index{|k,o| self[k].silenced = false}
end
|
#get(key) ⇒ Object
Also known as:
[]
40
41
42
43
|
# File 'lib/livecode/clock_recipients.rb', line 40
def get(key)
return nil unless self.has_key?(key)
@collection[key.to_sym]
end
|
#has_key?(key) ⇒ Boolean
24
25
26
|
# File 'lib/livecode/clock_recipients.rb', line 24
def has_key?(key)
(@collection.keys.map{|k| k}.include?(key.to_sym)) ? true : false
end
|
#keys ⇒ Object
20
21
22
|
# File 'lib/livecode/clock_recipients.rb', line 20
def keys
@collection.map{|k,o| k}
end
|
#set(key, obj = nil, &block) ⇒ Object
Also known as:
add, attach, []=
28
29
30
31
32
33
34
35
|
# File 'lib/livecode/clock_recipients.rb', line 28
def set(key, obj=nil, &block)
obj = block if block_given?
if obj
@collection[key.to_sym] = Silenceable.apply( obj )
elsif has_key?(key)
@collection.delete(key.to_sym)
end
end
|
#silence(*keys) ⇒ Object
Also known as:
mute
58
59
60
|
# File 'lib/livecode/clock_recipients.rb', line 58
def silence(*keys)
keys.each{|k| self[k].silenced = true}
end
|
#silence_all ⇒ Object
Also known as:
mute_all
63
64
65
|
# File 'lib/livecode/clock_recipients.rb', line 63
def silence_all
each_with_index{|k,o| self[k].silenced = true}
end
|
#solo(*keys) ⇒ Object
Also known as:
play
68
69
70
71
|
# File 'lib/livecode/clock_recipients.rb', line 68
def solo(*keys)
silence_all
keys.each{|k| self[k].silenced = false}
end
|