Class: BrowserStack::Worker

Inherits:
ApiRequest show all
Defined in:
lib/browser_stack/worker.rb

Instance Attribute Summary collapse

Attributes inherited from ApiRequest

#config, #http_client, #params, #request, #response, #uri

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiRequest

#api_error?, #authenticate, #commit, #error_message, #get_http_client, #parse_response, #set_uri

Constructor Details

#initialize(attributes = {}) ⇒ Worker

Returns a new instance of Worker.



4
5
6
7
8
9
10
11
12
# File 'lib/browser_stack/worker.rb', line 4

def initialize(attributes={})
  attributes.each do |name, value|
    begin
      send("#{name}=", value)
    rescue
      puts "invalid attribute #{name} in worker"
    end
  end
end

Instance Attribute Details

#browserObject

Returns the value of attribute browser.



3
4
5
# File 'lib/browser_stack/worker.rb', line 3

def browser
  @browser
end

#browser_versionObject

Returns the value of attribute browser_version.



3
4
5
# File 'lib/browser_stack/worker.rb', line 3

def browser_version
  @browser_version
end

#osObject

Returns the value of attribute os.



3
4
5
# File 'lib/browser_stack/worker.rb', line 3

def os
  @os
end

#os_versionObject

Returns the value of attribute os_version.



3
4
5
# File 'lib/browser_stack/worker.rb', line 3

def os_version
  @os_version
end

#timeoutObject

Returns the value of attribute timeout.



3
4
5
# File 'lib/browser_stack/worker.rb', line 3

def timeout
  @timeout
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/browser_stack/worker.rb', line 3

def url
  @url
end

Class Method Details

.create_worker(params = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/browser_stack/worker.rb', line 19

def create_worker(params={})
  worker = Worker.new(params)
  if worker.valid?
    worker.commit("/worker","post",params)
  else
  # raise some error
    raise "Not Valid should contain os,os_version,url parameter"
  end
  worker
end

.get_all_worker_statusObject



42
43
44
45
46
# File 'lib/browser_stack/worker.rb', line 42

def get_all_worker_status
  worker = Worker.new
  worker.commit("/workers")
  worker
end

.get_worker_status(worker_id) ⇒ Object



36
37
38
39
40
# File 'lib/browser_stack/worker.rb', line 36

def get_worker_status(worker_id)
  worker = Worker.new
  worker.commit("/worker/#{worker_id}")
  worker
end

.treminate_worker(worker_id) ⇒ Object



30
31
32
33
34
# File 'lib/browser_stack/worker.rb', line 30

def treminate_worker(worker_id)
  worker = Worker.new
  worker.commit("/worker/#{worker_id}","delete")
  worker
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/browser_stack/worker.rb', line 14

def valid?
   os && os_version && url
end