Module: Xi::Init
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, backend = nil, **opts) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/xi.rb', line 56
def method_missing(method, backend=nil, **opts)
backend ||= Xi.default_backend
super if backend.nil?
if !backend.is_a?(String) && !backend.is_a?(Symbol)
fail ArgumentError, "invalid backend '#{backend}'"
end
@streams ||= {}
@streams[backend] ||= {}
stream = @streams[backend][method] ||= begin
require "xi/#{backend}"
cls = Class.const_get("#{backend.to_s.camelize}::Stream")
cls.new(method, Xi.default_clock, **opts)
end
Pry.binding_for(self).local_variable_set(method, stream)
stream
end
|
Instance Method Details
#e(n, m, value = nil) ⇒ Object
48
49
50
|
# File 'lib/xi.rb', line 48
def e(n, m, value=nil)
Bjorklund.new([n, m].min, [n, m].max, value)
end
|
#peek(pattern, *args) ⇒ Object
40
41
42
|
# File 'lib/xi.rb', line 40
def peek(pattern, *args)
pattern.peek(*args)
end
|
#peek_events(pattern, *args) ⇒ Object
44
45
46
|
# File 'lib/xi.rb', line 44
def peek_events(pattern, *args)
pattern.peek_events(*args)
end
|
#s(str, *values) ⇒ Object
52
53
54
|
# File 'lib/xi.rb', line 52
def s(str, *values)
StepSequencer.new(str, *values)
end
|
#start_all ⇒ Object
36
37
38
|
# File 'lib/xi.rb', line 36
def start_all
@streams.each { |_, ss| ss.each { |_, s| s.start } }
end
|
#stop_all ⇒ Object
Also known as:
hush
31
32
33
|
# File 'lib/xi.rb', line 31
def stop_all
@streams.each { |_, ss| ss.each { |_, s| s.stop } }
end
|