Class: RTurk::Hit
- Inherits:
-
Object
show all
- Includes:
- XMLUtilities
- Defined in:
- lib/rturk/adapters/hit.rb
Instance Attribute Summary (collapse)
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
#map_content, #normalize_nested_params, #xml_to_hash
Constructor Details
- (Hit) initialize(id, source = nil, options = {})
58
59
60
61
|
# File 'lib/rturk/adapters/hit.rb', line 58
def initialize(id, source = nil, options={})
@id, @source = id, source
@include_assignment_summary = options[:include_assignment_summary]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *args)
105
106
107
108
109
110
111
|
# File 'lib/rturk/adapters/hit.rb', line 105
def method_missing(method, *args)
if @source.respond_to?(method)
@source.send(method, *args)
elsif self.details.respond_to?(method)
self.details.send(method)
end
end
|
Instance Attribute Details
- (Object) id
Returns the value of attribute id
56
57
58
|
# File 'lib/rturk/adapters/hit.rb', line 56
def id
@id
end
|
- (Object) source
Returns the value of attribute source
56
57
58
|
# File 'lib/rturk/adapters/hit.rb', line 56
def source
@source
end
|
Class Method Details
+ (Object) all
48
49
50
51
52
|
# File 'lib/rturk/adapters/hit.rb', line 48
def all
RTurk.SearchHITs.hits.inject([]) do |arr, hit|
arr << new(hit.id, hit); arr;
end
end
|
+ (Object) all_reviewable
42
43
44
45
46
|
# File 'lib/rturk/adapters/hit.rb', line 42
def all_reviewable
RTurk.GetReviewableHITs.hit_ids.inject([]) do |arr, hit_id|
arr << new(hit_id); arr
end
end
|
+ (Object) create(*args, &blk)
26
27
28
29
|
# File 'lib/rturk/adapters/hit.rb', line 26
def create(*args, &blk)
response = RTurk::CreateHIT(*args, &blk)
new(response.hit_id, response)
end
|
+ (Object) find(id)
Find all the details for a HIT You could do this manually with new(id), and
only call for the details you need, or simply call this and get them all,
and immediately see any errors
35
36
37
38
39
40
|
# File 'lib/rturk/adapters/hit.rb', line 35
def find(id)
h = new(id)
h.details
h.assignments
h
end
|
Instance Method Details
- (Object) assignments
64
65
66
67
68
69
|
# File 'lib/rturk/adapters/hit.rb', line 64
def assignments
@assignments ||=
RTurk::GetAssignmentsForHIT(:hit_id => self.id).assignments.inject([]) do |arr, assignment|
arr << RTurk::Assignment.new(assignment.assignment_id, assignment)
end
end
|
- (Object) bonus_payments
84
85
86
|
# File 'lib/rturk/adapters/hit.rb', line 84
def bonus_payments
RTurk::GetBonusPayments(:hit_id => id).payments
end
|
- (Object) details
71
72
73
74
|
# File 'lib/rturk/adapters/hit.rb', line 71
def details
@details ||= RTurk::GetHIT(:hit_id => self.id,
:include_assignment_summary => !!@include_assignment_summary)
end
|
- (Object) disable!
92
93
94
|
# File 'lib/rturk/adapters/hit.rb', line 92
def disable!
RTurk::DisableHIT(:hit_id => self.id)
end
|
- (Object) dispose!
88
89
90
|
# File 'lib/rturk/adapters/hit.rb', line 88
def dispose!
RTurk::DisposeHIT(:hit_id => self.id)
end
|
- (Object) expire!
80
81
82
|
# File 'lib/rturk/adapters/hit.rb', line 80
def expire!
RTurk::ForceExpireHIT(:hit_id => self.id)
end
|
- (Object) extend!(options = {})
76
77
78
|
# File 'lib/rturk/adapters/hit.rb', line 76
def extend!(options = {})
RTurk::ExtendHIT(options.merge({:hit_id => self.id}))
end
|
- (Object) url
97
98
99
100
101
102
103
|
# File 'lib/rturk/adapters/hit.rb', line 97
def url
if RTurk.sandbox?
"http://workersandbox.mturk.com/mturk/preview?groupId=#{self.type_id}" else
"http://mturk.com/mturk/preview?groupId=#{self.type_id}" end
end
|