Class: RTurk::SearchHITs

Inherits:
Operation show all
Defined in:
lib/rturk/operations/search_hits.rb

Constant Summary

SORT_BY =
{ :title => 'Title', :reward => 'Reward', :expiration => 'Expiration', :created_at => 'CreationTime', :enumeration => 'Enumeration'}
SORT_ORDER =
{:ascending => 'Ascending', :descending => 'Descending', :asc => 'Ascending', :desc => 'Descending'}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Operation

#check_params, create, default_params, #default_params, #initialize, #request, require_params, required_params, set_operation

Constructor Details

This class inherits a constructor from RTurk::Operation

Instance Attribute Details

#page_numberObject

You can call this operation without any parameters and get an unsorted list or you can pass in a :sort_by => => :ascending

You can sort by

:title
:reward
:expiration
:created_at
:enumeration


13
14
15
# File 'lib/rturk/operations/search_hits.rb', line 13

def page_number
  @page_number
end

#page_sizeObject

You can call this operation without any parameters and get an unsorted list or you can pass in a :sort_by => => :ascending

You can sort by

:title
:reward
:expiration
:created_at
:enumeration


13
14
15
# File 'lib/rturk/operations/search_hits.rb', line 13

def page_size
  @page_size
end

#sort_byObject

You can call this operation without any parameters and get an unsorted list or you can pass in a :sort_by => => :ascending

You can sort by

:title
:reward
:expiration
:created_at
:enumeration


13
14
15
# File 'lib/rturk/operations/search_hits.rb', line 13

def sort_by
  @sort_by
end

#sort_orderObject

You can call this operation without any parameters and get an unsorted list or you can pass in a :sort_by => => :ascending

You can sort by

:title
:reward
:expiration
:created_at
:enumeration


13
14
15
# File 'lib/rturk/operations/search_hits.rb', line 13

def sort_order
  @sort_order
end

#sort_propertyObject

You can call this operation without any parameters and get an unsorted list or you can pass in a :sort_by => => :ascending

You can sort by

:title
:reward
:expiration
:created_at
:enumeration


13
14
15
# File 'lib/rturk/operations/search_hits.rb', line 13

def sort_property
  @sort_property
end

Instance Method Details

#parse(xml) ⇒ Object



18
19
20
# File 'lib/rturk/operations/search_hits.rb', line 18

def parse(xml)
  RTurk::SearchHITsResponse.new(xml)
end

#set_sort_byObject



32
33
34
35
36
37
# File 'lib/rturk/operations/search_hits.rb', line 32

def set_sort_by
  if @sort_by
    @sort_property = SORT_BY[@sort_by.keys.first]
    @sort_order = SORT_ORDER[@sort_by.values.first]
  end
end

#to_paramsObject



22
23
24
25
26
27
28
29
30
# File 'lib/rturk/operations/search_hits.rb', line 22

def to_params
  self.set_sort_by
  {
    'SortProperty' => self.sort_property,
    'SortDirection' => self.sort_order,
    'PageSize' => (self.page_size || 100),
    'PageNumber' => (self.page_number || 1)
  }
end