Sha256: 61adea4e592ebb8b1c2aa8d4de95430fb99de2166c583639aecbbfba81c7ab29

Contents?: true

Size: 1019 Bytes

Versions: 10

Compression:

Stored size: 1019 Bytes

Contents

require 'time'

module RTurk
  class Assignment
    attr_reader :id, :source

    def initialize(id, source = nil)
      @id, @source = id, source
    end

    def bonus_payments
      RTurk::GetBonusPayments(:assignment_id => id).payments
    end

    def approve!(feedback = nil)
      RTurk::ApproveAssignment(:assignment_id => self.id, :feedback => feedback)
    end

    def reject!(reason)
      RTurk::RejectAssignment(:assignment_id => self.id, :feedback => reason)
    end

    def bonus!(amount, reason)
      RTurk::GrantBonus(:assignment_id => self.id, :worker_id => self.worker_id, :amount => amount, :feedback => reason)
    end

    def worker
      RTurk::Worker.new(self.worker_id)
    end

    def submitted?
      status == 'Submitted'
    end

    def approved?
      status == 'Approved'
    end

    def rejected?
      status == 'Rejected'
    end

    def method_missing(method, *args)
      if self.source.respond_to?(method)
        self.source.send(method, *args)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rturk-2.8.0 lib/rturk/adapters/assignment.rb
rturk-2.7.0 lib/rturk/adapters/assignment.rb
rturk-2.6.0 lib/rturk/adapters/assignment.rb
rturk-2.5.2 lib/rturk/adapters/assignment.rb
rturk-2.5.0 lib/rturk/adapters/assignment.rb
rturk-2.4.1 lib/rturk/adapters/assignment.rb
rturk-2.4.0 lib/rturk/adapters/assignment.rb
rturk-2.3.6 lib/rturk/adapters/assignment.rb
rturk-2.3.5 lib/rturk/adapters/assignment.rb
rturk-2.3.4 lib/rturk/adapters/assignment.rb