Class: Typingpool::Amazon::HIT::Assignment

Inherits:
Object
  • Object
show all
Defined in:
lib/typingpool/amazon/hit/assignment.rb,
lib/typingpool/amazon/hit/assignment/empty.rb

Direct Known Subclasses

Empty

Defined Under Namespace

Classes: Empty

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rturk_hit) ⇒ Assignment

Constructor. Takes an RTurk::Hit instance.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/typingpool/amazon/hit/assignment.rb', line 12

def initialize(rturk_hit)
  if assignment = rturk_hit.assignments[0] #expensive!
    @id = assignment.id
    @status = assignment.status
    @worker_id = assignment.worker_id
    @submitted_at = assignment.
    if answers = assignment.answers
      @answers = answers.to_hash
    end
  end
end

Instance Attribute Details

#idObject (readonly)

See the RTurk documentation and Amazon Mechanical Turk API documentation for more on these fields.



9
10
11
# File 'lib/typingpool/amazon/hit/assignment.rb', line 9

def id
  @id
end

#statusObject (readonly)

See the RTurk documentation and Amazon Mechanical Turk API documentation for more on these fields.



9
10
11
# File 'lib/typingpool/amazon/hit/assignment.rb', line 9

def status
  @status
end

#submitted_atObject (readonly)

See the RTurk documentation and Amazon Mechanical Turk API documentation for more on these fields.



9
10
11
# File 'lib/typingpool/amazon/hit/assignment.rb', line 9

def 
  @submitted_at
end

#worker_idObject (readonly)

See the RTurk documentation and Amazon Mechanical Turk API documentation for more on these fields.



9
10
11
# File 'lib/typingpool/amazon/hit/assignment.rb', line 9

def worker_id
  @worker_id
end

Instance Method Details

#answersObject

Returns the answers associated with this assignment as a hash. If there are no answers, returns an empty hash.



26
27
28
# File 'lib/typingpool/amazon/hit/assignment.rb', line 26

def answers
  @answers ||= {}
end

#at_amazonObject

Returms an RTurk::Assignment object corresponding to this assignment.



37
38
39
# File 'lib/typingpool/amazon/hit/assignment.rb', line 37

def at_amazon
  RTurk::Assignment.new(@id)
end

#bodyObject

Returns the transcription submitted by the user as raw text.



31
32
33
# File 'lib/typingpool/amazon/hit/assignment.rb', line 31

def body
  (answers['transcription'] || answers['1']).to_s
end