Method: CF::RobotWorker#initialize

Defined in:
lib/cf/robot_worker.rb

#initialize(options = {}) ⇒ RobotWorker

Initialize new Robot Worker

Usage Example:

In Block DSL way

line = CF::Line.create("sentiment_robot","Digitization") do |l|
  CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
  CF::Station.create({:line => l, :type => "work"}) do |s|
    CF::RobotWorker.new({:station => s, :settings => {:document => "{url}", :sanitize => true}, :type => "sentiment_robot"})
  end
end

OR

In Plain Ruby way

line = CF::Line.new("sentiment_robot_1","Digitization")
input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
line.input_formats input_format

station = CF::Station.new({:type => "work"})
line.stations station

worker =  CF::RobotWorker.new({:settings => {:document => "{url}", :sanitize => true}, :type => "sentiment_robot"})
line.stations.first.worker = worker


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/cf/robot_worker.rb', line 46

def initialize(options={})
  @type = options[:type].nil? ? nil : options[:type].camelize
  @settings = options[:settings]
  station = options[:station]
  
  if station
    request = options[:settings].merge(:type => @type)
    resp = self.class.post("/lines/#{CF.}/#{station.line_title.downcase}/stations/#{station.index}/workers.json", :worker => request)
    if resp.code != 200
      self.errors = resp.error.message
    end
    self.number = resp.number
    self.reward = resp.reward
    self.station = station
    station.worker = self
  end
end