Class: QLab::Machine
- Inherits:
-
Communicator
- Object
- Communicator
- QLab::Machine
- Defined in:
- lib/qlab-ruby/machine.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#name ⇒ Object
Returns the value of attribute name.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
- #alwaysReply=(value) ⇒ Object
- #close ⇒ Object
-
#connect ⇒ Object
Open and return a connection to the running QLab instance.
- #connected? ⇒ Boolean
-
#connection ⇒ Object
Reference to the running QLab instance.
-
#find_workspace(params = {}) ⇒ Object
Find a workspace according to the given params.
-
#initialize(_address, _port) ⇒ Machine
constructor
Connect to a running QLab instance.
- #refresh ⇒ Object
-
#workspaces ⇒ Object
The workspaces provided by the connected QLab instance.
Methods inherited from Communicator
Constructor Details
#initialize(_address, _port) ⇒ Machine
Connect to a running QLab instance. ‘address` can be a domain name or an IP Address.
7 8 9 10 11 12 |
# File 'lib/qlab-ruby/machine.rb', line 7 def initialize(_address, _port) self.name = _address self.address = _address self.port = _port connect end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
3 4 5 |
# File 'lib/qlab-ruby/machine.rb', line 3 def address @address end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/qlab-ruby/machine.rb', line 3 def name @name end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/qlab-ruby/machine.rb', line 3 def port @port end |
Instance Method Details
#alwaysReply=(value) ⇒ Object
75 76 77 78 |
# File 'lib/qlab-ruby/machine.rb', line 75 def alwaysReply=(value) # send set command alwaysReply(value) end |
#close ⇒ Object
64 65 66 67 |
# File 'lib/qlab-ruby/machine.rb', line 64 def close @connection.close @connection = nil end |
#connect ⇒ Object
Open and return a connection to the running QLab instance
27 28 29 30 31 32 33 |
# File 'lib/qlab-ruby/machine.rb', line 27 def connect if !connected? @connection = OSC::TCP::Client.new(@address, @port) else connection end end |
#connected? ⇒ Boolean
60 61 62 |
# File 'lib/qlab-ruby/machine.rb', line 60 def connected? !(@connection.nil? || ('/version').nil?) end |
#connection ⇒ Object
Reference to the running QLab instance
36 37 38 |
# File 'lib/qlab-ruby/machine.rb', line 36 def connection @connection || connect end |
#find_workspace(params = {}) ⇒ Object
Find a workspace according to the given params.
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/qlab-ruby/machine.rb', line 47 def find_workspace params={} workspaces.find do |ws| matches = true # match each key to the given workspace params.keys.each do |key| matches = matches && (ws.send(key.to_sym) == params[key]) end matches end end |
#refresh ⇒ Object
69 70 71 72 73 |
# File 'lib/qlab-ruby/machine.rb', line 69 def refresh close connect load_workspaces end |
#workspaces ⇒ Object
The workspaces provided by the connected QLab instance
41 42 43 |
# File 'lib/qlab-ruby/machine.rb', line 41 def workspaces @workspaces || load_workspaces end |