module Xi::Init

Public Instance Methods

e(n, m, value=nil) click to toggle source
# File lib/xi.rb, line 48
def e(n, m, value=nil)
  Bjorklund.new([n, m].min, [n, m].max, value)
end
hush()
Alias for: stop_all
method_missing(method, backend=nil, **opts) click to toggle source
Calls superclass method
# 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

  # Define (or overwrite) a local variable named +method+ with the stream
  Pry.binding_for(self).local_variable_set(method, stream)

  stream
end
peek(pattern, *args) click to toggle source
# File lib/xi.rb, line 40
def peek(pattern, *args)
  pattern.peek(*args)
end
peek_events(pattern, *args) click to toggle source
# File lib/xi.rb, line 44
def peek_events(pattern, *args)
  pattern.peek_events(*args)
end
s(str, *values) click to toggle source
# File lib/xi.rb, line 52
def s(str, *values)
  StepSequencer.new(str, *values)
end
start_all() click to toggle source
# File lib/xi.rb, line 36
def start_all
  @streams.each { |_, ss| ss.each { |_, s| s.start } }
end
stop_all() click to toggle source
# File lib/xi.rb, line 31
def stop_all
  @streams.each { |_, ss| ss.each { |_, s| s.stop } }
end
Also aliased as: hush