Class: CrowdFlower::Unit
- Inherits:
-
Object
- Object
- CrowdFlower::Unit
- Includes:
- Defaults
- Defined in:
- lib/ruby-crowdflower/unit.rb
Instance Attribute Summary collapse
-
#job ⇒ Object
readonly
Returns the value of attribute job.
Instance Method Summary collapse
- #all(page = 1, limit = 1000) ⇒ Object
- #copy(unit_id, job_id, data = {}) ⇒ Object
- #create(data, gold = nil) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(job) ⇒ Unit
constructor
A new instance of Unit.
- #split(on, with = " ") ⇒ Object
Methods included from Defaults
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
#job ⇒ Object (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 |