Class: BlackStack::NextBot::RemoteCommand

Inherits:
BaseRemoteObject show all
Includes:
BaseCommand
Defined in:
lib/remotecommand.rb

Overview

The “remote” (or API class) that will be receive the data from an API call.

Constant Summary

Constants included from BaseCommand

BaseCommand::STATUS_CANCELED, BaseCommand::STATUS_FAILURE, BaseCommand::STATUS_ONGOING, BaseCommand::STATUS_PENDING, BaseCommand::STATUS_SUCCESS, BaseCommand::TYPE_CLOSE, BaseCommand::TYPE_GOTO, BaseCommand::TYPE_LOGIN, BaseCommand::TYPE_START_BOT, BaseCommand::TYPE_TRAFFIC

Instance Attribute Summary collapse

Attributes inherited from BaseRemoteObject

#descriptor

Instance Method Summary collapse

Methods included from BaseCommand

statusColor, statusDescription, statuses, typeDescription, types

Constructor Details

#initialize(the_browser = nil) ⇒ RemoteCommand

browser: is a browser created from the BrowserFactory class.



60
61
62
# File 'lib/remotecommand.rb', line 60

def initialize(the_browser=nil)
  self.browser = the_browser
end

Instance Attribute Details

#browserObject

:browser: is the browser where the bot will operate.



12
13
14
# File 'lib/remotecommand.rb', line 12

def browser
  @browser
end

#idObject

:id is the ID of the record in the “routine” table. :params is an array of RemoteParam objects. :steps is an array of RemoteSteps objects.



17
18
19
# File 'lib/remotecommand.rb', line 17

def id
  @id
end

#id_workerObject

:id is the ID of the record in the “routine” table. :params is an array of RemoteParam objects. :steps is an array of RemoteSteps objects.



17
18
19
# File 'lib/remotecommand.rb', line 17

def id_worker
  @id_worker
end

#param_goto_urlObject

:id is the ID of the record in the “routine” table. :params is an array of RemoteParam objects. :steps is an array of RemoteSteps objects.



17
18
19
# File 'lib/remotecommand.rb', line 17

def param_goto_url
  @param_goto_url
end

#param_login_id_domainObject

:id is the ID of the record in the “routine” table. :params is an array of RemoteParam objects. :steps is an array of RemoteSteps objects.



17
18
19
# File 'lib/remotecommand.rb', line 17

def 
  
end

#param_start_id_lnuserObject

:id is the ID of the record in the “routine” table. :params is an array of RemoteParam objects. :steps is an array of RemoteSteps objects.



17
18
19
# File 'lib/remotecommand.rb', line 17

def param_start_id_lnuser
  @param_start_id_lnuser
end

#param_start_usernameObject

:id is the ID of the record in the “routine” table. :params is an array of RemoteParam objects. :steps is an array of RemoteSteps objects.



17
18
19
# File 'lib/remotecommand.rb', line 17

def param_start_username
  @param_start_username
end

#typeObject

:id is the ID of the record in the “routine” table. :params is an array of RemoteParam objects. :steps is an array of RemoteSteps objects.



17
18
19
# File 'lib/remotecommand.rb', line 17

def type
  @type
end

Instance Method Details

#build(h) ⇒ Object

generate all the hierarchy of the bot (routines, steps,

> params) from a hash descriptor.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/remotecommand.rb', line 21

def build(h)
  super(h)
  self.id = h['id']
  self.id_worker = h['id_worker']
  self.type = h['type']
  # start command params

  self.param_start_id_lnuser = h['param_start_id_lnuser']
  self.param_start_username = h['param_start_username']
  # login command params

  self. = h['param_login_id_domain']
  # goto command params

  self.param_goto_url = h['param_goto_url']
  # TODO: map here all the other attributes of the record in the "command" table, 

  # regarding every one of the possible "type" of steps. 

end

#create_childObject

based on the “type” attribute, create an instance of the

> regarding child class, to invoke the “run” method of

> such child class.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/remotecommand.rb', line 40

def create_child()
  return RemoteStepStartBot.new(self.browser).build(self.descritor) if self.type == TYPE_START_BOT
  return RemoteStepLogin.new(self.browser).build(self.descritor) if self.type == 
  return RemoteStepGoto.new(self.browser).build(self.descritor) if self.type == TYPE_GOTO
  
  # TODO: add RemoteStepStartScraper

  # TODO: add RemoteStepTraffic

  
  #return RemoteStepFind.new(self.browser).build(self.descritor) if self.type == TYPE_FIND

  #return RemoteStepMouse.new(self.browser).build(self.descritor) if self.type == TYPE_MOUSE

  #return RemoteStepWrite.new(self.browser).build(self.descritor) if self.type == TYPE_WRITE

  #return RemoteStepDelay.new(self.browser).build(self.descritor) if self.type == TYPE_DELAY

  #return RemoteStepCall.new(self.browser).build(self.descritor) if self.type == TYPE_CALL

  #return RemoteStepIf.new(self.browser).build(self.descritor) if self.type == TYPE_IF

  #return RemoteStepExists.new(self.browser).build(self.descritor) if self.type == TYPE_EXISTS

  #return RemoteStepEach.new(self.browser).build(self.descritor) if self.type == TYPE_EACH

  return RemoteStepClose.new(self.browser).build(self.descritor) if self.type == TYPE_CLOSE
end

#runObject

run the specified operation for this “type” of “step”



65
66
67
# File 'lib/remotecommand.rb', line 65

def run()
  raise 'This is an abstract method. Each child of the RemoteCommand class will code its own "run" method.'
end