Class: CrowdFlower::Unit

Inherits:
Object
  • Object
show all
Includes:
Defaults
Defined in:
lib/ruby-crowdflower/unit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Defaults

included

Constructor Details

#initialize(job) ⇒ Unit

Returns a new instance of Unit.



6
7
8
9
10
# File 'lib/ruby-crowdflower/unit.rb', line 6

def initialize(job)
  @job = job
  Unit.base_uri CrowdFlower.with_domain("/jobs/#{@job.id}/units")
  Unit.default_params CrowdFlower.key
end

Instance Attribute Details

#jobObject (readonly)

Returns the value of attribute job.



4
5
6
# File 'lib/ruby-crowdflower/unit.rb', line 4

def job
  @job
end

Instance Method Details

#all(page = 1, limit = 1000) ⇒ Object



12
13
14
# File 'lib/ruby-crowdflower/unit.rb', line 12

def all(page = 1, limit = 1000)
  Unit.get("", {:query => {:limit => limit, :page => page}})
end

#copy(unit_id, job_id, data = {}) ⇒ Object



24
25
26
# File 'lib/ruby-crowdflower/unit.rb', line 24

def copy(unit_id, job_id, data = {})
  Unit.get("/#{unit_id}/copy", {:query => {:unit => {:job_id => job_id, :data => data}}})
end

#create(data, gold = nil) ⇒ Object



20
21
22
# File 'lib/ruby-crowdflower/unit.rb', line 20

def create(data, gold = nil)
  Unit.post("", {:query => {:unit => {:data => data.to_json, :golden => gold}}})
end

#get(id) ⇒ Object



16
17
18
# File 'lib/ruby-crowdflower/unit.rb', line 16

def get(id)
  Unit.get("/#{id}")
end

#split(on, with = " ") ⇒ Object



28
29
30
# File 'lib/ruby-crowdflower/unit.rb', line 28

def split(on, with = " ")
  Unit.get("/split", {:query => {:on => on, :with => with}})
end