Class: QLab::Workspace
- Inherits:
-
Communicator
- Object
- Communicator
- QLab::Workspace
- Defined in:
- lib/qlab-ruby/workspace.rb
Overview
“uniqueID”: string,
"displayName": string
"hasPasscode": number
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#passcode ⇒ Object
Returns the value of attribute passcode.
Instance Method Summary collapse
- #connection ⇒ Object
- #cue_lists ⇒ Object
-
#cues ⇒ Object
all cues in this workspace in a flat list.
- #find_cue(params = {}) ⇒ Object
- #has_cues? ⇒ Boolean
- #id ⇒ Object
-
#initialize(data, machine) ⇒ Workspace
constructor
Load a workspace with the attributes given in ‘data`.
- #name ⇒ Object
- #passcode? ⇒ Boolean
- #refresh ⇒ Object
Methods inherited from Communicator
Constructor Details
#initialize(data, machine) ⇒ Workspace
Load a workspace with the attributes given in ‘data`
11 12 13 14 |
# File 'lib/qlab-ruby/workspace.rb', line 11 def initialize data, machine @machine = machine self.data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
8 9 10 |
# File 'lib/qlab-ruby/workspace.rb', line 8 def data @data end |
#passcode ⇒ Object
Returns the value of attribute passcode.
8 9 10 |
# File 'lib/qlab-ruby/workspace.rb', line 8 def passcode @passcode end |
Instance Method Details
#connection ⇒ Object
26 27 28 |
# File 'lib/qlab-ruby/workspace.rb', line 26 def connection @machine.connection end |
#cue_lists ⇒ Object
53 54 55 56 |
# File 'lib/qlab-ruby/workspace.rb', line 53 def cue_lists refresh @cue_lists end |
#cues ⇒ Object
all cues in this workspace in a flat list
43 44 45 46 47 |
# File 'lib/qlab-ruby/workspace.rb', line 43 def cues cue_lists.map do |cl| load_cues(cl, []) end.flatten.compact end |
#find_cue(params = {}) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/qlab-ruby/workspace.rb', line 80 def find_cue params={} cues.find do |cue| matches = true # match each key to the given cue params.keys.each do |key| matches = matches && (cue.send(key.to_sym) == params[key]) end matches end end |
#has_cues? ⇒ Boolean
49 50 51 |
# File 'lib/qlab-ruby/workspace.rb', line 49 def has_cues? cues.size > 0 end |
#id ⇒ Object
38 39 40 |
# File 'lib/qlab-ruby/workspace.rb', line 38 def id data['uniqueID'] end |
#name ⇒ Object
30 31 32 |
# File 'lib/qlab-ruby/workspace.rb', line 30 def name data['displayName'] end |
#passcode? ⇒ Boolean
34 35 36 |
# File 'lib/qlab-ruby/workspace.rb', line 34 def passcode? !!data['hasPasscode'] end |
#refresh ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/qlab-ruby/workspace.rb', line 58 def refresh if passcode? if passcode.nil? raise WorkspaceConnectionError.new("Workspace '#{ name }' requires a passcode.") end args = [workspace_command('connect'), ('%04i' % passcode)] else args = [workspace_command('connect')] end connect_response = (*args) if connect_response == 'ok' @cue_lists = [] cues_response = workspace_command('cueLists') cues_response.each do |cuelist| @cue_lists << QLab::CueList.new(cuelist, self) end end end |