Sha256: a992b0faef282529c9020ba6d25d81c7ffa4f9681ebc1de1e6cf8ad41b8a5a37

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

module CrowdFlower
  class Unit < Base
    attr_reader :job
    
    def initialize(job)
      super job.connection
      @job = job
      connect
    end

    def resource_uri
      "/jobs/#{@job.id}/units"
    end
    
    def all(page = 1, limit = 1000)
      connection.get(resource_uri, {:query => {:limit => limit, :page => page}})
    end
    
    def get(id)
      connection.get("#{resource_uri}/#{id}")
    end
    
    def ping
      connection.get("#{resource_uri}/ping")
    end
    
    def judgments(id)
      connection.get("#{resource_uri}/#{id}/judgments")
    end
    
    def create(data, gold = false)
      connection.post(resource_uri, {:body => {:unit => {:data => data.to_json, :golden => gold}}})
    end
    
    def copy(unit_id, job_id, data = {})
      connection.get("#{resource_uri}/#{unit_id}/copy", {:query => {:unit => {:job_id => job_id, :data => data}}})
    end
    
    def split(on, with = " ")
      connection.get("#{resource_uri}/split", {:query => {:on => on, :with => with}})
    end
    
    def cancel(unit_id)
      connection.post("#{resource_uri}/#{unit_id}/cancel.json")
    end

    def request_more_judgments(unit_id, nb_judgments = 1)
      connection.post("#{resource_uri}/#{unit_id}/request_more_judgments.json", :body => {:nb_judgments => nb_judgments})
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
crowdflower-0.6.8 lib/crowdflower/unit.rb
crowdflower-0.6.7 lib/crowdflower/unit.rb
crowdflower-0.6.3 lib/crowdflower/unit.rb